summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2019-04-18 17:38:51 (GMT)
committerYann Collet <cyan@fb.com>2019-04-18 17:38:51 (GMT)
commit3f558163ad74ee9553839aedb211c08a835f23a3 (patch)
treef4654811902d2786049a43bca18f54a93cb99967
parent8f0e7440633b956484626a432af3eae70c436419 (diff)
downloadlz4-3f558163ad74ee9553839aedb211c08a835f23a3.zip
lz4-3f558163ad74ee9553839aedb211c08a835f23a3.tar.gz
lz4-3f558163ad74ee9553839aedb211c08a835f23a3.tar.bz2
fuzzer: fixed scan-build leak warning
the program exit(), so there is no need to track and dealloc every buffer.
-rw-r--r--tests/fuzzer.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/tests/fuzzer.c b/tests/fuzzer.c
index 234be7c..14cd8a0 100644
--- a/tests/fuzzer.c
+++ b/tests/fuzzer.c
@@ -331,7 +331,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
if (cond) { \
printf("Test %u : ", testNb); printf(__VA_ARGS__); \
printf(" (seed %u, cycle %u) \n", seed, cycleNb); \
- goto _output_error; \
+ exit(1); \
}
# define FUZ_DISPLAYTEST(...) { \
@@ -347,7 +347,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
/* init */
if(!CNBuffer || !compressedBuffer || !decodedBuffer) {
DISPLAY("Not enough memory to start fuzzer tests");
- goto _output_error;
+ exit(1);
}
if ( LZ4_initStream(&LZ4dict, sizeof(LZ4dict)) == NULL) abort();
if ( LZ4_initStreamHC(&LZ4dictHC, sizeof(LZ4dictHC)) == NULL) abort();
@@ -505,7 +505,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
decodedBuffer[blockSize-1] = 0;
ret = LZ4_decompress_fast(cBuffer_exact, decodedBuffer, blockSize-1);
FUZ_CHECKTEST(ret>=0, "LZ4_decompress_fast should have failed, due to Output Size being too small");
- FUZ_CHECKTEST(decodedBuffer[blockSize-1], "LZ4_decompress_fast overrun specified output buffer");
+ FUZ_CHECKTEST(decodedBuffer[blockSize-1]!=0, "LZ4_decompress_fast overrun specified output buffer");
/* Test decoding with one byte too much => must fail */
FUZ_DISPLAYTEST();
@@ -960,20 +960,13 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
printf("ratio with dict: %0.3f%%\n", (double)ccbytes/bytes*100);
/* release memory */
- {
-_exit:
- free(CNBuffer);
- free(compressedBuffer);
- free(decodedBuffer);
- FUZ_freeLowAddr(lowAddrBuffer, labSize);
- free(stateLZ4);
- free(stateLZ4HC);
- return result;
-
-_output_error:
- result = 1;
- goto _exit;
- }
+ free(CNBuffer);
+ free(compressedBuffer);
+ free(decodedBuffer);
+ FUZ_freeLowAddr(lowAddrBuffer, labSize);
+ free(stateLZ4);
+ free(stateLZ4HC);
+ return result;
}
@@ -1388,8 +1381,6 @@ static void FUZ_unitTests(int compressionLevel)
printf("All unit tests completed successfully compressionLevel=%d \n", compressionLevel);
return;
-_output_error:
- exit(1);
}