[mutter] monitor-config-store: Replace key when replacing config
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-config-store: Replace key when replacing config
- Date: Mon, 17 Apr 2017 09:46:06 +0000 (UTC)
commit 0608ae2d4e8e69a7dbfa92f5e5313da8b7a6197b
Author: Jonas Ådahl <jadahl gmail com>
Date: Thu Apr 13 13:03:12 2017 +0800
monitor-config-store: Replace key when replacing config
g_hash_table_insert() doesn't replace the key. This was a problem
because the key was owned by the value inserted into the hash table, so
when a value was removed, the key was freed, meaning that the key in
the hash table was no pointing to freed memory. Fix this by using
g_hash_table_replace() instead, which work the same except that it
replaces the key with the one passed. This means that the key of a
value in the hash table is always the key owned by the value.
https://bugzilla.gnome.org/show_bug.cgi?id=777732
src/backends/meta-monitor-config-store.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/backends/meta-monitor-config-store.c b/src/backends/meta-monitor-config-store.c
index 7c4c624..aa7f08a 100644
--- a/src/backends/meta-monitor-config-store.c
+++ b/src/backends/meta-monitor-config-store.c
@@ -1185,8 +1185,8 @@ void
meta_monitor_config_store_add (MetaMonitorConfigStore *config_store,
MetaMonitorsConfig *config)
{
- g_hash_table_insert (config_store->configs,
- config->key, g_object_ref (config));
+ g_hash_table_replace (config_store->configs,
+ config->key, g_object_ref (config));
if (!config_store->custom_file)
meta_monitor_config_store_save (config_store);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]