summaryrefslogtreecommitdiff
path: root/tests/fuzzer.c
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2020-10-02 18:02:41 -0700
committerYann Collet <cyan@fb.com>2020-10-02 18:03:12 -0700
commit4b97866333523b2bc778d88fe68b6b86ea26ce6e (patch)
tree3722f697d79b83db88d2d6547f6c934607c74492 /tests/fuzzer.c
parent389eacdfeaefee5326de2352ff42aa0195f156a0 (diff)
downloadlz4-4b97866333523b2bc778d88fe68b6b86ea26ce6e.tar.gz
lz4-4b97866333523b2bc778d88fe68b6b86ea26ce6e.tar.bz2
lz4-4b97866333523b2bc778d88fe68b6b86ea26ce6e.zip
reduce new test stack usage
use heap instead
Diffstat (limited to 'tests/fuzzer.c')
-rw-r--r--tests/fuzzer.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/fuzzer.c b/tests/fuzzer.c
index 4fef4af..3eb5789 100644
--- a/tests/fuzzer.c
+++ b/tests/fuzzer.c
@@ -1201,22 +1201,24 @@ static void FUZ_unitTests(int compressionLevel)
}
DISPLAYLEVEL(3, "LZ4_initStreamHC with multiple valid alignments : ");
- { struct {
+ { typedef struct {
LZ4_streamHC_t hc1;
char c1;
LZ4_streamHC_t hc2;
char c2;
LZ4_streamHC_t hc3;
- } shc;
- (void)shc.c1; (void)shc.c2; /* tell cppcheck these variables are unused */
+ } shct;
+ shct* const shc = malloc(sizeof(*shc));
+ assert(shc != NULL);
+ memset(shc, 0, sizeof(*shc));
DISPLAYLEVEL(3, "hc1(%p) hc2(%p) hc3(%p) size(0x%x): ",
- &(shc.hc1), &(shc.hc2), &(shc.hc3), (unsigned)sizeof(LZ4_streamHC_t));
- FUZ_CHECKTEST( LZ4_initStreamHC(&(shc.hc1), sizeof(shc.hc1)) == NULL, "hc1 (%p) failed init", &(shc.hc1) );
- FUZ_CHECKTEST( LZ4_initStreamHC(&(shc.hc2), sizeof(shc.hc2)) == NULL, "hc2 (%p) failed init", &(shc.hc2) );
- FUZ_CHECKTEST( LZ4_initStreamHC(&(shc.hc3), sizeof(shc.hc3)) == NULL, "hc3 (%p) failed init", &(shc.hc3) );
- FUZ_CHECKTEST( LZ4_initStreamHC((char*)&(shc.hc1) + 1, sizeof(shc.hc1)) != NULL,
- "hc1+1 (%p) init must fail, due to bad alignment", (char*)&(shc.hc1) + 1 );
- /* no need to release anything : LZ4_streamHC_t is a simple POD type */
+ &(shc->hc1), &(shc->hc2), &(shc->hc3), (unsigned)sizeof(LZ4_streamHC_t));
+ FUZ_CHECKTEST( LZ4_initStreamHC(&(shc->hc1), sizeof(shc->hc1)) == NULL, "hc1 (%p) failed init", &(shc->hc1) );
+ FUZ_CHECKTEST( LZ4_initStreamHC(&(shc->hc2), sizeof(shc->hc2)) == NULL, "hc2 (%p) failed init", &(shc->hc2) );
+ FUZ_CHECKTEST( LZ4_initStreamHC(&(shc->hc3), sizeof(shc->hc3)) == NULL, "hc3 (%p) failed init", &(shc->hc3) );
+ FUZ_CHECKTEST( LZ4_initStreamHC((char*)&(shc->hc1) + 1, sizeof(shc->hc1)) != NULL,
+ "hc1+1 (%p) init must fail, due to bad alignment", (char*)&(shc->hc1) + 1 );
+ free(shc);
}
DISPLAYLEVEL(3, "OK \n");