Fix null pointer addition
This commit is contained in:
@@ -490,6 +490,19 @@ static int basicUnitTests(U32 const seed, double compressibility)
|
||||
}
|
||||
DISPLAYLEVEL(3, "OK \n");
|
||||
|
||||
DISPLAYLEVEL(3, "test%3i : compress a NULL input with each level : ", testNb++);
|
||||
{ int level = -1;
|
||||
ZSTD_CCtx* cctx = ZSTD_createCCtx();
|
||||
if (!cctx) goto _output_error;
|
||||
for (level = -1; level <= ZSTD_maxCLevel(); ++level) {
|
||||
CHECK_Z( ZSTD_compress(compressedBuffer, compressedBufferSize, NULL, 0, level) );
|
||||
CHECK_Z( ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, level) );
|
||||
CHECK_Z( ZSTD_compress2(cctx, compressedBuffer, compressedBufferSize, NULL, 0) );
|
||||
}
|
||||
ZSTD_freeCCtx(cctx);
|
||||
}
|
||||
DISPLAYLEVEL(3, "OK \n");
|
||||
|
||||
DISPLAYLEVEL(3, "test%3d : check CCtx size after compressing empty input : ", testNb++);
|
||||
{ ZSTD_CCtx* const cctx = ZSTD_createCCtx();
|
||||
size_t const r = ZSTD_compressCCtx(cctx, compressedBuffer, compressedBufferSize, NULL, 0, 19);
|
||||
|
||||
@@ -509,6 +509,33 @@ static int basicUnitTests(U32 seed, double compressibility)
|
||||
}
|
||||
DISPLAYLEVEL(3, "OK \n");
|
||||
|
||||
DISPLAYLEVEL(3, "test%3i : NULL buffers : ", testNb++);
|
||||
inBuff.src = NULL;
|
||||
inBuff.size = 0;
|
||||
inBuff.pos = 0;
|
||||
outBuff.dst = NULL;
|
||||
outBuff.size = 0;
|
||||
outBuff.pos = 0;
|
||||
CHECK_Z( ZSTD_compressStream(zc, &outBuff, &inBuff) );
|
||||
CHECK(inBuff.pos != inBuff.size, "Entire input should be consumed");
|
||||
CHECK_Z( ZSTD_endStream(zc, &outBuff) );
|
||||
outBuff.dst = (char*)(compressedBuffer);
|
||||
outBuff.size = compressedBufferSize;
|
||||
outBuff.pos = 0;
|
||||
{ size_t const r = ZSTD_endStream(zc, &outBuff);
|
||||
CHECK(r != 0, "Error or some data not flushed (ret=%zu)", r);
|
||||
}
|
||||
inBuff.src = outBuff.dst;
|
||||
inBuff.size = outBuff.pos;
|
||||
inBuff.pos = 0;
|
||||
outBuff.dst = NULL;
|
||||
outBuff.size = 0;
|
||||
outBuff.pos = 0;
|
||||
CHECK_Z( ZSTD_initDStream(zd) );
|
||||
{ size_t const ret = ZSTD_decompressStream(zd, &outBuff, &inBuff);
|
||||
if (ret != 0) goto _output_error;
|
||||
}
|
||||
DISPLAYLEVEL(3, "OK\n");
|
||||
/* _srcSize compression test */
|
||||
DISPLAYLEVEL(3, "test%3i : compress_srcSize %u bytes : ", testNb++, COMPRESSIBLE_NOISE_LENGTH);
|
||||
CHECK_Z( ZSTD_initCStream_srcSize(zc, 1, CNBufferSize) );
|
||||
|
||||
Reference in New Issue
Block a user