]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[huf] Fix null pointer addition
authorNick Terrell <terrelln@meta.com>
Mon, 20 Nov 2023 20:04:30 +0000 (12:04 -0800)
committerNick Terrell <nickrterrell@gmail.com>
Mon, 20 Nov 2023 22:13:01 +0000 (17:13 -0500)
`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.

lib/decompress/huf_decompress.c

index b8795efb552932e180f64e598d27eb75e7be3ef7..0c43c656de843c0a4b35e72174af3ec26c4255e5 100644 (file)
@@ -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);