aboutsummaryrefslogtreecommitdiffstats
path: root/libemail-engine
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2014-06-26 01:02:52 +0800
committerMilan Crha <mcrha@redhat.com>2014-06-26 01:06:33 +0800
commit26e359645f68583ac2d851e577f37df593056fa4 (patch)
treedf3fcc0cd2a8af73f3db902ce4044894253be021 /libemail-engine
parentd4b8a56865843be13e7fa6b8990f8915024994e0 (diff)
downloadgsoc2013-evolution-26e359645f68583ac2d851e577f37df593056fa4.tar
gsoc2013-evolution-26e359645f68583ac2d851e577f37df593056fa4.tar.gz
gsoc2013-evolution-26e359645f68583ac2d851e577f37df593056fa4.tar.bz2
gsoc2013-evolution-26e359645f68583ac2d851e577f37df593056fa4.tar.lz
gsoc2013-evolution-26e359645f68583ac2d851e577f37df593056fa4.tar.xz
gsoc2013-evolution-26e359645f68583ac2d851e577f37df593056fa4.tar.zst
gsoc2013-evolution-26e359645f68583ac2d851e577f37df593056fa4.zip
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.
Diffstat (limited to 'libemail-engine')
-rw-r--r--libemail-engine/mail-folder-cache.c3
1 files changed, 2 insertions, 1 deletions
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));