Fix srcSize=0 edge case

dev
senhuang42 2020-11-10 15:33:33 -05:00
parent 022e6d81e7
commit 48405b4633
1 changed files with 10 additions and 0 deletions

View File

@ -4694,6 +4694,16 @@ static size_t ZSTD_compressSequences_internal(void* dst, size_t dstCapacity,
BYTE* op = (BYTE*)dst;
DEBUGLOG(4, "ZSTD_compressSequences_internal srcSize: %zu, inSeqsSize: %zu", srcSize, inSeqsSize);
/* Special case: empty frame */
if (remaining == 0) {
U32 const cBlockHeader24 = 1 /* last block */ + (((U32)bt_raw)<<1);
RETURN_ERROR_IF(dstCapacity<4, dstSize_tooSmall, "No room for empty frame block header");
MEM_writeLE32(op, cBlockHeader24);
op += ZSTD_blockHeaderSize;
dstCapacity -= ZSTD_blockHeaderSize;
cSize += ZSTD_blockHeaderSize;
}
while (remaining) {
U32 cBlockSize;
int additionalByteAdjustment;