Fixing issues with double usage of data.
This commit is contained in:
parent
a71bbba7be
commit
3932fcfebc
@ -23,21 +23,24 @@ static ZSTD_DCtx *dctx = NULL;
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size)
|
||||
{
|
||||
|
||||
FUZZ_dataProducer_t *producer = FUZZ_dataProducer_create(src, size);
|
||||
|
||||
int i;
|
||||
if (!dctx) {
|
||||
dctx = ZSTD_createDCtx();
|
||||
FUZZ_ASSERT(dctx);
|
||||
}
|
||||
/* Run it 10 times over 10 output sizes. Reuse the context. */
|
||||
for (i = 0; i < 10; ++i) {
|
||||
|
||||
size_t const bufSize = FUZZ_dataProducer_uint32Range(producer, 0, 2 * size);
|
||||
void* rBuf = malloc(bufSize);
|
||||
FUZZ_ASSERT(rBuf);
|
||||
|
||||
/* Restrict to remaining data. If we run out of data while generating params,
|
||||
we should still continue and let decompression happen on empty data. */
|
||||
size = FUZZ_dataProducer_remainingBytes(producer);
|
||||
|
||||
ZSTD_decompressDCtx(dctx, rBuf, bufSize, src, size);
|
||||
free(rBuf);
|
||||
}
|
||||
|
||||
FUZZ_dataProducer_free(producer);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user