From: Nick Terrell Date: Mon, 20 Nov 2023 20:04:30 +0000 (-0800) Subject: [huf] Fix null pointer addition X-Git-Tag: v1.5.6^2~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd4de1dd7a78ccff933025cf1de08a75d310802b;p=thirdparty%2Fzstd.git [huf] Fix null pointer addition `HUF_DecompressFastArgs_init()` was adding 0 to NULL. Fix it by exiting early for empty outputs. This is no change in behavior, because the function was already exiting 0 in this case, just slightly later. --- diff --git a/lib/decompress/huf_decompress.c b/lib/decompress/huf_decompress.c index b8795efb5..0c43c656d 100644 --- a/lib/decompress/huf_decompress.c +++ b/lib/decompress/huf_decompress.c @@ -203,6 +203,11 @@ static size_t HUF_DecompressFastArgs_init(HUF_DecompressFastArgs* args, void* ds if (!MEM_isLittleEndian() || MEM_32bits()) return 0; + /* Avoid nullptr addition */ + if (dstSize == 0) + return 0; + assert(dst != NULL); + /* strict minimum : jump table + 1 byte per stream */ if (srcSize < 10) return ERROR(corruption_detected);