From: Nick Terrell Date: Thu, 25 May 2023 21:35:49 +0000 (-0700) Subject: Fix UBSAN issue (zero addition to NULL) X-Git-Tag: v1.5.6^2~159 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d01a2c69296cff9bd052b797b2be1055a96cd644;p=thirdparty%2Fzstd.git Fix UBSAN issue (zero addition to NULL) Fix UBSAN issue that came up internally. --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 521e5e5d6..19446b63f 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -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) {