Fix a memory leak in blacklist component (#420)

This commit is contained in:
Thibault Charbonnier 2021-12-02 14:59:52 -08:00 committed by GitHub
parent 04cee3c27d
commit 6eb799bc63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,17 +74,12 @@ void blacklist_load(Blacklist *blacklist)
fileContent[fileSize] = 0;
if(fileContent && strlen(fileContent)) {
char *p=strchr(fileContent,'\n');
while (p!=NULL) {
p=strchr(p+1,'\n');
}
char *pb=fileContent, *pe, *s;
char *pb=fileContent, *pe;
pe=strchr(fileContent, '\n');
while(pe!=NULL) {
*pe=0;
if(!hashset_contains(blacklist->set,pb)) {
s=hstr_strdup(pb);
hashset_add(blacklist->set,s);
hashset_add(blacklist->set,pb);
}
pb=pe+1;
pe=strchr(pb, '\n');
@ -151,8 +146,10 @@ void blacklist_destroy(Blacklist *blacklist, bool freeBlacklist)
exit(EXIT_FAILURE);
}
}
free(keys[i]);
}
fclose(outputFile);
free(keys);
} else {
if(access(fileName, F_OK) != -1) {
FILE *outputFile = fopen(fileName, "wb");