]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed read error 106/head
authorYann Collet <yann.collet.73@gmail.com>
Sat, 9 Jan 2016 01:10:40 +0000 (02:10 +0100)
committerYann Collet <yann.collet.73@gmail.com>
Sat, 9 Jan 2016 01:10:40 +0000 (02:10 +0100)
lib/zstd_compress.c

index e66fedbe511743ac1fedd683b4dadc6e93311b8f..399f81169620cb163bceee47e4fbf3a5ca8c8259 100644 (file)
@@ -1797,6 +1797,7 @@ static ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, int
 static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc, void* dst, size_t maxDstSize, const void* src, size_t srcSize)
 {
     ZSTD_blockCompressor blockCompressor = ZSTD_selectBlockCompressor(zc->params.strategy, zc->lowLimit < zc->dictLimit);
+    if (srcSize < MIN_CBLOCK_SIZE+3) return 0;   /* don't even attempt compression below a certain srcSize */
     return blockCompressor(zc, dst, maxDstSize, src, srcSize);
 }
 
@@ -1832,6 +1833,7 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* ctxPtr,
         if (cSize == 0)
         {
             cSize = ZSTD_noCompressBlock(op, maxDstSize, ip, blockSize);   /* block is not compressible */
+            if (ZSTD_isError(cSize)) return cSize;
         }
         else
         {
@@ -1928,7 +1930,6 @@ size_t ZSTD_compressContinue (ZSTD_CCtx* zc,
 size_t ZSTD_compressBlock(ZSTD_CCtx* zc, void* dst, size_t maxDstSize, const void* src, size_t srcSize)
 {
     if (srcSize > BLOCKSIZE) return ERROR(srcSize_wrong);
-    if (srcSize < MIN_CBLOCK_SIZE+3) return 0;   /* don't even attempt compression below a certain srcSize */
     return ZSTD_compressContinue_internal(zc, dst, maxDstSize, src, srcSize, 0);
 }