1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-30 22:23:13 +03:00

[libzstd] Fix estimate with negative levels

* Fix `ZSTD_estimateCCtxSize()` with negative levels.
* Fix `ZSTD_estimateCStreamSize()` with negative levels.
* Add a unit test to test for this error.
This commit is contained in:
Nick Terrell
2018-12-18 14:24:49 -08:00
parent 517d8c984c
commit d7def456d8
2 changed files with 13 additions and 2 deletions

View File

@ -694,6 +694,17 @@ static int basicUnitTests(U32 seed, double compressibility)
free(staticDCtxBuffer);
}
DISPLAYLEVEL(3, "test%3i : Static negative levels : ", testNb++);
{ size_t const cctxSizeN1 = ZSTD_estimateCCtxSize(-1);
size_t const cctxSizeP1 = ZSTD_estimateCCtxSize(1);
size_t const cstreamSizeN1 = ZSTD_estimateCStreamSize(-1);
size_t const cstreamSizeP1 = ZSTD_estimateCStreamSize(1);
if (!(0 < cctxSizeN1 && cctxSizeN1 <= cctxSizeP1)) goto _output_error;
if (!(0 < cstreamSizeN1 && cstreamSizeN1 <= cstreamSizeP1)) goto _output_error;
}
DISPLAYLEVEL(3, "OK \n");
/* ZSTDMT simple MT compression test */
DISPLAYLEVEL(3, "test%3i : create ZSTDMT CCtx : ", testNb++);