[fix] Always return dstSize_tooSmall when it is the case
This commit is contained in:
@@ -579,11 +579,11 @@ static size_t ZSTD_copyRawBlock(void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize)
|
||||
{
|
||||
DEBUGLOG(5, "ZSTD_copyRawBlock");
|
||||
RETURN_ERROR_IF(srcSize > dstCapacity, dstSize_tooSmall, "");
|
||||
if (dst == NULL) {
|
||||
if (srcSize == 0) return 0;
|
||||
RETURN_ERROR(dstBuffer_null, "");
|
||||
}
|
||||
RETURN_ERROR_IF(srcSize > dstCapacity, dstSize_tooSmall, "");
|
||||
memcpy(dst, src, srcSize);
|
||||
return srcSize;
|
||||
}
|
||||
@@ -592,11 +592,11 @@ static size_t ZSTD_setRleBlock(void* dst, size_t dstCapacity,
|
||||
BYTE b,
|
||||
size_t regenSize)
|
||||
{
|
||||
RETURN_ERROR_IF(regenSize > dstCapacity, dstSize_tooSmall, "");
|
||||
if (dst == NULL) {
|
||||
if (regenSize == 0) return 0;
|
||||
RETURN_ERROR(dstBuffer_null, "");
|
||||
}
|
||||
RETURN_ERROR_IF(regenSize > dstCapacity, dstSize_tooSmall, "");
|
||||
memset(dst, b, regenSize);
|
||||
return regenSize;
|
||||
}
|
||||
|
||||
@@ -1084,14 +1084,14 @@ ZSTD_decompressSequences_body( ZSTD_DCtx* dctx,
|
||||
#endif
|
||||
DEBUGLOG(6, "regenerated sequence size : %u", (U32)oneSeqSize);
|
||||
BIT_reloadDStream(&(seqState.DStream));
|
||||
op += oneSeqSize;
|
||||
/* gcc and clang both don't like early returns in this loop.
|
||||
* gcc doesn't like early breaks either.
|
||||
* Instead save an error and report it at the end.
|
||||
* When there is an error, don't increment op, so we don't
|
||||
* overwrite.
|
||||
* Instead break and check for an error at the end of the loop.
|
||||
*/
|
||||
if (UNLIKELY(ZSTD_isError(oneSeqSize))) error = oneSeqSize;
|
||||
else op += oneSeqSize;
|
||||
if (UNLIKELY(ZSTD_isError(oneSeqSize))) {
|
||||
error = oneSeqSize;
|
||||
break;
|
||||
}
|
||||
if (UNLIKELY(!--nbSeq)) break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user