diff options
author | Anestis Bechtsoudis <anestis@census-labs.com> | 2016-01-10 15:06:09 +0200 |
---|---|---|
committer | Anestis Bechtsoudis <anestis@census-labs.com> | 2016-01-10 15:06:09 +0200 |
commit | 3a8e16f85bb188a5b5fded75d8c8c0550c44e064 (patch) | |
tree | 96af5c7f3eb30c37ee2b275281dbbff821abdf83 /files.c | |
parent | 58c45d285bc13715b610c2b61d8dbce69e376a1c (diff) | |
download | honggfuzz-3a8e16f85bb188a5b5fded75d8c8c0550c44e064.tar.gz |
FILES: Fix memory leaks
Signed-off-by: Anestis Bechtsoudis <anestis@census-labs.com>
Diffstat (limited to 'files.c')
-rw-r--r-- | files.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -290,9 +290,9 @@ bool files_parseDictionary(honggfuzz_t * hfuzz) return false; } + char *lineptr = NULL; + size_t n = 0; for (;;) { - char *lineptr = NULL; - size_t n = 0; if (getdelim(&lineptr, &n, '\0', fDict) == -1) { break; } @@ -302,6 +302,7 @@ bool files_parseDictionary(honggfuzz_t * hfuzz) PLOG_E("Realloc failed (sz=%zu)", (hfuzz->dictionaryCnt + 1) * sizeof(hfuzz->dictionary[0])); fclose(fDict); + free(lineptr); return false; } hfuzz->dictionary[hfuzz->dictionaryCnt] = lineptr; @@ -312,6 +313,7 @@ bool files_parseDictionary(honggfuzz_t * hfuzz) } LOG_I("Loaded %zu words from the dictionary", hfuzz->dictionaryCnt); fclose(fDict); + free(lineptr); return true; } @@ -412,9 +414,9 @@ bool files_parseBlacklist(honggfuzz_t * hfuzz) return false; } + char *lineptr = NULL; + size_t n = 0; for (;;) { - char *lineptr = NULL; - size_t n = 0; if (getline(&lineptr, &n, fBl) == -1) { break; } @@ -425,6 +427,7 @@ bool files_parseBlacklist(honggfuzz_t * hfuzz) PLOG_E("realloc failed (sz=%zu)", (hfuzz->blacklistCnt + 1) * sizeof(hfuzz->blacklist[0])); fclose(fBl); + free(lineptr); return false; } @@ -437,6 +440,7 @@ bool files_parseBlacklist(honggfuzz_t * hfuzz) LOG_F ("Blacklist file not sorted. Use 'tools/createStackBlacklist.sh' to sort records"); fclose(fBl); + free(lineptr); return false; } } @@ -449,6 +453,7 @@ bool files_parseBlacklist(honggfuzz_t * hfuzz) LOG_F("Empty stack hashes blacklist file '%s'", hfuzz->blacklistFile); } fclose(fBl); + free(lineptr); return true; } |