]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fix UBSAN issue (zero addition to NULL)
authorNick Terrell <terrelln@meta.com>
Thu, 25 May 2023 21:35:49 +0000 (14:35 -0700)
committerNick Terrell <nickrterrell@gmail.com>
Fri, 26 May 2023 20:43:47 +0000 (13:43 -0700)
Fix UBSAN issue that came up internally.

lib/compress/zstd_compress.c

index 521e5e5d681974958663fe5502d41edfa98d847b..19446b63ff3a93f520145013b7a048e3cfc99703 100644 (file)
@@ -5951,7 +5951,7 @@ static size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
     if (zcs->appliedParams.inBufferMode == ZSTD_bm_stable) {
         assert(input->pos >= zcs->stableIn_notConsumed);
         input->pos -= zcs->stableIn_notConsumed;
-        ip -= zcs->stableIn_notConsumed;
+        if (ip) ip -= zcs->stableIn_notConsumed;
         zcs->stableIn_notConsumed = 0;
     }
     if (zcs->appliedParams.inBufferMode == ZSTD_bm_buffered) {