[zstd] Fix NULL pointer addition in ZSTD_checkContinuity()

Don't start a new section when `dstSize == 0` to avoid NULL
pointer addition.
This commit is contained in:
Nick Terrell
2021-02-05 12:18:06 -08:00
parent 824dff4917
commit f9b1e711ba
3 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -1517,9 +1517,9 @@ ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
}
void ZSTD_checkContinuity(ZSTD_DCtx* dctx, const void* dst)
void ZSTD_checkContinuity(ZSTD_DCtx* dctx, const void* dst, size_t dstSize)
{
if (dst != dctx->previousDstEnd) { /* not contiguous */
if (dst != dctx->previousDstEnd && dstSize > 0) { /* not contiguous */
dctx->dictEnd = dctx->previousDstEnd;
dctx->virtualStart = (const char*)dst - ((const char*)(dctx->previousDstEnd) - (const char*)(dctx->prefixStart));
dctx->prefixStart = dst;
@@ -1533,7 +1533,7 @@ size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx,
const void* src, size_t srcSize)
{
size_t dSize;
ZSTD_checkContinuity(dctx, dst);
ZSTD_checkContinuity(dctx, dst, dstCapacity);
dSize = ZSTD_decompressBlock_internal(dctx, dst, dstCapacity, src, srcSize, /* frame */ 0);
dctx->previousDstEnd = (char*)dst + dSize;
return dSize;