]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Work around nullptr-with-nonzero-offset warning
authorNick Terrell <terrelln@meta.com>
Thu, 24 Aug 2023 23:33:42 +0000 (16:33 -0700)
committerNick Terrell <nickrterrell@gmail.com>
Fri, 25 Aug 2023 17:20:59 +0000 (13:20 -0400)
See comment.

lib/decompress/zstd_decompress.c

index 94eb95151b53da4b421a8cb62b64f5280a72c19d..ccfd84fa42d2d8ecf0deccb3da41bbdd1f49d478 100644 (file)
@@ -1548,6 +1548,12 @@ size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx)
     dctx->stage = ZSTDds_getFrameHeaderSize;
     dctx->processedCSize = 0;
     dctx->decodedSize = 0;
+    /* Set to non-null because ZSTD_prefetchMatch() may end up doing addition
+     * with this value for corrupted frames. However, it then just passes the
+     * pointer to PREFETCH_L1(), which doesn't require valid pointers. But,
+     * if it is NULL we get nullptr-with-nonzero-offset UBSAN warnings.
+     */
+    dctx->previousDstEnd = "";
     dctx->previousDstEnd = NULL;
     dctx->prefixStart = NULL;
     dctx->virtualStart = NULL;