From 26e359645f68583ac2d851e577f37df593056fa4 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 25 Jun 2014 19:02:52 +0200 Subject: store_info_insert_folder_info: Use g_hash_table_replace() to avoid use-after-free The previously used g_hash_table_insert() replaces only value for keys which are already included in the hash table, but as the key is owned by the value and freed together with the value, then here should be used g_hash_table_replace(), which replaces both key and value, thus avoids the use-after-free on the hash table's key. --- libemail-engine/mail-folder-cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libemail-engine/mail-folder-cache.c b/libemail-engine/mail-folder-cache.c index d6bb1e5e30..f5d49a3ca7 100644 --- a/libemail-engine/mail-folder-cache.c +++ b/libemail-engine/mail-folder-cache.c @@ -386,7 +386,8 @@ store_info_insert_folder_info (StoreInfo *store_info, folder_info_ht = store_info->folder_info_ht; - g_hash_table_insert ( + /* Replace both key and value, because the key gets freed as soon as the value */ + g_hash_table_replace ( folder_info_ht, folder_info->full_name, folder_info_ref (folder_info)); -- cgit v1.2.3