added test that exposes zero offset to null pointer error when built with clang

This commit is contained in:
Danielle Rozenblit
2022-09-07 08:58:08 -07:00
parent 4a6783bbbb
commit 282a955d33
+27 -8
View File
@@ -548,14 +548,33 @@ static int basicUnitTests(U32 seed, double compressibility)
{ size_t const ret = ZSTD_decompressStream(zd, &outBuff, &inBuff); { size_t const ret = ZSTD_decompressStream(zd, &outBuff, &inBuff);
if (ret != 0) goto _output_error; if (ret != 0) goto _output_error;
} }
inBuff.src = NULL;
inBuff.size = 0; {
inBuff.pos = 0; const char* test = "aa";
outBuff.dst = NULL; inBuff.src = test;
outBuff.size = 0; inBuff.size = 2;
outBuff.pos = 0; inBuff.pos = 0;
CHECK_Z( ZSTD_initDStream(zd) ); outBuff.dst = NULL;
CHECK_Z(ZSTD_decompressStream(zd, &outBuff, &inBuff)); 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) );
CHECK_Z(ZSTD_decompressStream(zd, &outBuff, &inBuff));
}
DISPLAYLEVEL(3, "OK\n"); DISPLAYLEVEL(3, "OK\n");
/* _srcSize compression test */ /* _srcSize compression test */