diff options
Diffstat (limited to 'src/liblzma/common/index_hash.c')
-rw-r--r-- | src/liblzma/common/index_hash.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/liblzma/common/index_hash.c b/src/liblzma/common/index_hash.c index 5c9d3140..18556a1a 100644 --- a/src/liblzma/common/index_hash.c +++ b/src/liblzma/common/index_hash.c @@ -325,9 +325,16 @@ lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in, } out: - // Update the CRC32, - index_hash->crc32 = lzma_crc32(in + in_start, - *in_pos - in_start, index_hash->crc32); + // Update the CRC32. + // + // Avoid null pointer + 0 (undefined behavior) in "in + in_start". + // In such a case we had no input and thus in_used == 0. + { + const size_t in_used = *in_pos - in_start; + if (in_used > 0) + index_hash->crc32 = lzma_crc32(in + in_start, + in_used, index_hash->crc32); + } return ret; } |