]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed +/-1 error for pledgedSrcSizePlusOne
authorYann Collet <cyan@fb.com>
Sat, 17 Jun 2017 00:01:46 +0000 (17:01 -0700)
committerYann Collet <cyan@fb.com>
Sat, 17 Jun 2017 00:02:35 +0000 (17:02 -0700)
lib/compress/zstd_compress.c

index 937fd3107c9ddc6a10da26fc2ad3b902d0377727..6286c5aa6378422d8e587a0a9915b596917a07d9 100644 (file)
@@ -3219,7 +3219,7 @@ size_t ZSTD_compressEnd (ZSTD_CCtx* cctx,
         DEBUGLOG(5, "end of frame : controlling src size");
         if (cctx->pledgedSrcSizePlusOne != cctx->consumedSrcSize+1) {
             DEBUGLOG(5, "error : pledgedSrcSize = %u, while realSrcSize = %u",
-                (U32)cctx->frameContentSize, (U32)cctx->consumedSrcSize);
+                (U32)cctx->pledgedSrcSizePlusOne-1, (U32)cctx->consumedSrcSize);
             return ERROR(srcSize_wrong);
     }   }
     return cSize + endResult;
@@ -3789,7 +3789,7 @@ size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
         ZSTD_parameters params = cctx->requestedParams;
         if (cctx->compressionLevel != ZSTD_CLEVEL_CUSTOM)
             params.cParams = ZSTD_getCParams(cctx->compressionLevel,
-                                    cctx->pledgedSrcSizePlusOne+1, 0 /* dictSize */);
+                                    cctx->pledgedSrcSizePlusOne-1, 0 /* dictSize */);
 
 #ifdef ZSTD_MULTITHREAD
         if (cctx->nbThreads > 1) {
@@ -3798,7 +3798,7 @@ size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
         } else
 #endif
         {
-            CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->pledgedSrcSizePlusOne+1) );
+            CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->pledgedSrcSizePlusOne-1) );
     }   }
 
 #ifdef ZSTD_MULTITHREAD