mirror of
https://github.com/dvorka/hstr.git
synced 2024-09-20 06:46:13 +08:00
Fix a memory leak in blacklist component (#420)
This commit is contained in:
parent
04cee3c27d
commit
6eb799bc63
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue