Leaving room for checksum
This commit is contained in:
parent
4b1ac69f19
commit
dba767c0bb
@ -2480,8 +2480,11 @@ static size_t ZSTD_compressBlock_targetCBlockSize(ZSTD_CCtx* zc,
|
|||||||
* enough for SuperBlock compression.
|
* enough for SuperBlock compression.
|
||||||
* In such case, fall back to normal compression. This is possible because
|
* In such case, fall back to normal compression. This is possible because
|
||||||
* targetCBlockSize is best effort not a guarantee. */
|
* targetCBlockSize is best effort not a guarantee. */
|
||||||
if (cSize != ERROR(dstSize_tooSmall)) return cSize;
|
if (cSize == ERROR(dstSize_tooSmall) || (dstCapacity - cSize) < 4) {
|
||||||
else {
|
/* We check (dstCapacity - cSize) < 4 above because we have to make sure
|
||||||
|
* to leave enouch room for the checksum that will eventually get added in
|
||||||
|
* the epilogue. Otherwise, we're just going to throw the dstSize_tooSmall
|
||||||
|
* error there instead of here */
|
||||||
BYTE* const ostart = (BYTE*)dst;
|
BYTE* const ostart = (BYTE*)dst;
|
||||||
/* If ZSTD_noCompressSuperBlock fails with dstSize_tooSmall,
|
/* If ZSTD_noCompressSuperBlock fails with dstSize_tooSmall,
|
||||||
* compress normally.
|
* compress normally.
|
||||||
@ -2498,7 +2501,7 @@ static size_t ZSTD_compressBlock_targetCBlockSize(ZSTD_CCtx* zc,
|
|||||||
MEM_writeLE24(ostart, cBlockHeader24);
|
MEM_writeLE24(ostart, cBlockHeader24);
|
||||||
cSize += ZSTD_blockHeaderSize;
|
cSize += ZSTD_blockHeaderSize;
|
||||||
}
|
}
|
||||||
}
|
} else return cSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ZSTD_isError(cSize) && cSize != 0) {
|
if (!ZSTD_isError(cSize) && cSize != 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user