Only use offset optimization for string types in HEADERIMPORT_FAST (#398)

Only string types benefit from the offset-based optimization, for other
types the operation is a trivial constant-time calculation anyway and
getting inaccurate length information (due to alignment of next item
getting included) in return for a non-optimization is nothing but a
bad trade.
This commit is contained in:
Panu Matilainen 2018-02-20 13:00:39 +02:00
parent 5ac4305bdd
commit 0093584a6a
1 changed files with 2 additions and 1 deletions

View File

@ -497,7 +497,8 @@ static int regionSwab(indexEntry entry, int il, int dl,
if (dataEnd && (unsigned char *)ie.data >= dataEnd)
return -1;
if (fast && il > 1) {
/* The offset optimization is only relevant for string types */
if (fast && il > 1 && typeSizes[ie.info.type] == -1) {
ie.length = ntohl(pe[1].offset) - ie.info.offset;
} else {
ie.length = dataLength(ie.info.type, ie.data, ie.info.count,