From 71ba5d12d6989ae65ca406f9a6d25c49135b319c Mon Sep 17 00:00:00 2001 From: Andrius Mitkus Date: Tue, 7 Apr 2020 23:06:59 +0300 Subject: [PATCH] Avoid NULL ptr arithmetic UB --- miniz_tdef.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miniz_tdef.c b/miniz_tdef.c index 313a03c..13e03a2 100644 --- a/miniz_tdef.c +++ b/miniz_tdef.c @@ -1094,7 +1094,7 @@ static mz_bool tdefl_compress_normal(tdefl_compressor *d) mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK, ins_pos = d->m_lookahead_pos + d->m_lookahead_size - 2; mz_uint hash = (d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK]; mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(src_buf_left, TDEFL_MAX_MATCH_LEN - d->m_lookahead_size); - const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process; + const mz_uint8 *pSrc_end = pSrc ? pSrc + num_bytes_to_process : NULL; src_buf_left -= num_bytes_to_process; d->m_lookahead_size += num_bytes_to_process; while (pSrc != pSrc_end)