Skip to content

Commit

Permalink
Fix minor memory leaks in traverse_dir() and find_flag_file()
Browse files Browse the repository at this point in the history
  • Loading branch information
aufau committed Aug 30, 2018
1 parent ae7a444 commit 036dc2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/country-filter.c
Expand Up @@ -159,6 +159,7 @@ int geoip_id_by_ip(struct in_addr in) {

static char* find_flag_file(int id) {
gchar file[] = "flags/lan.png";
gchar* file_lwr;
gchar* filename;

if (id != LAN_GeoIPid) {
Expand All @@ -168,7 +169,9 @@ static char* find_flag_file(int id) {
strcpy(file+strlen("flags/")+2, ".png");
}

filename = find_pixmap_directory(g_ascii_strdown(file, -1));
file_lwr = g_ascii_strdown(file, -1);
filename = find_pixmap_directory(file_lwr);
g_free(file_lwr);

return filename;
}
Expand Down
7 changes: 3 additions & 4 deletions src/q3maps.c
Expand Up @@ -525,12 +525,11 @@ void traverse_dir(const char* startdir, FoundFileFunction found_file, FoundDirFu
dirstack = g_slist_prepend(dirstack, dse);

while (dirstack) {
GSList* current = dirstack;
dirstack = g_slist_remove_link(dirstack, dirstack);

dse = current->data;
dse = dirstack->data;
curdir = dse->name;

dirstack = g_slist_delete_link(dirstack, dirstack);

dir = opendir(curdir);
if (!dir) {
perror(curdir);
Expand Down

0 comments on commit 036dc2b

Please sign in to comment.