]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/fuzzing: Free memory after successful load in fuzz_tiniparser
authorAndrew Bartlett <abartlet@samba.org>
Thu, 7 Nov 2019 03:52:48 +0000 (16:52 +1300)
committerJeremy Allison <jra@samba.org>
Mon, 18 Nov 2019 21:02:52 +0000 (21:02 +0000)
Otherwise we have a memory leak and so fail the Google oss-fuzz check_build test.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Nov 18 21:02:52 UTC 2019 on sn-devel-184

lib/fuzzing/fuzz_tiniparser.c

index ccc50da183a75edf1c5dabed8a016d938f73043e..6908f1815d7c49f14c0d8ce04f9e23b09fab86de 100644 (file)
@@ -28,6 +28,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
 int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
 {
        FILE *fp = NULL;
+       struct tiniparser_dictionary *d = NULL;
 
        if (len == 0) {
                /*
@@ -39,7 +40,10 @@ int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len)
 
        fp = fmemopen(buf, len, "r");
 
-       tiniparser_load_stream(fp);
+       d = tiniparser_load_stream(fp);
+       if (d != NULL) {
+               tiniparser_freedict(d);
+       }
 
        fclose(fp);