Skip to content

Commit

Permalink
Fix nasty double free crashes
Browse files Browse the repository at this point in the history
Old GTK+ versions seemed to be robust about this double free so we seen
that crashes or 100% CPU usages just with modern versions.

This patch takes care of it on two places:
1. Hashes will not be freed by g_hash_table_destroy when empty
2. NULLify the enty variable after free
  • Loading branch information
mowgli committed Feb 15, 2016
1 parent e9fc136 commit 4ca4c1f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/collect-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,14 @@ static void collect_manager_entry_free_data(CollectManagerEntry *entry)
collect_manager_action_unref(action);
}
g_list_free(entry->add_list);
g_hash_table_destroy(entry->oldpath_hash);
g_hash_table_destroy(entry->newpath_hash);
if (g_hash_table_size(entry->oldpath_hash) > 0)
g_hash_table_destroy(entry->oldpath_hash);
else
g_hash_table_unref(entry->oldpath_hash);
if (g_hash_table_size(entry->newpath_hash) > 0)
g_hash_table_destroy(entry->newpath_hash);
else
g_hash_table_unref(entry->newpath_hash);
}

static void collect_manager_entry_init_data(CollectManagerEntry *entry)
Expand Down Expand Up @@ -704,6 +710,8 @@ static void collect_manager_refresh(void)
else
{
collect_manager_entry_free(entry);

entry = NULL;
}
}
}
Expand Down

0 comments on commit 4ca4c1f

Please sign in to comment.