From 01b73949afbffbdd2b3465fdd44b3b93de56efb5 Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Sun, 7 Sep 2014 21:15:11 +0200 Subject: [PATCH] Duplicate the action_id before inserting in the hash table If we are trying to insert a duplicate action in the parsed_actions hash table, parsed_action_free() will be called and will free the action_id while the element is still in the table. Things will be go wrong when the new values are inserted. Be sure we are duplicating and freeing the action_id used as the hash table key. https://bugs.freedesktop.org/show_bug.cgi?id=83590 --- src/polkitbackend/polkitbackendactionpool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/polkitbackend/polkitbackendactionpool.c b/src/polkitbackend/polkitbackendactionpool.c index bc14381..4199b57 100644 --- a/src/polkitbackend/polkitbackendactionpool.c +++ b/src/polkitbackend/polkitbackendactionpool.c @@ -134,7 +134,7 @@ polkit_backend_action_pool_init (PolkitBackendActionPool *pool) priv->parsed_actions = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, + g_free, (GDestroyNotify) parsed_action_free); priv->parsed_files = g_hash_table_new_full (g_str_hash, @@ -1003,7 +1003,7 @@ _end (void *data, const char *el) action->implicit_authorization_inactive = pd->implicit_authorization_inactive; action->implicit_authorization_active = pd->implicit_authorization_active; - g_hash_table_insert (priv->parsed_actions, action->action_id, action); + g_hash_table_insert (priv->parsed_actions, g_strdup (action->action_id), action); /* we steal these hash tables */ pd->annotations = NULL; -- 2.1.0