update_desktop_file_entry: don't double-free strings if added to entry before failure
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 17 Jan 2011 11:45:47 +0000 (11:45 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Wed, 16 Feb 2011 14:47:08 +0000 (14:47 +0000)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33126

bus/activation.c

index 00d4be6..f69bf20 100644 (file)
@@ -389,6 +389,11 @@ update_desktop_file_entry (BusActivation       *activation,
       entry->systemd_service = systemd_service;
       entry->refcount = 1;
 
+      /* ownership has been transferred to entry, do not free separately */
+      name = NULL;
+      exec = NULL;
+      user = NULL;
+      systemd_service = NULL;
       entry->s_dir = s_dir;
       entry->filename = _dbus_strdup (_dbus_string_get_const_data (filename));
       if (!entry->filename)
@@ -433,6 +438,12 @@ update_desktop_file_entry (BusActivation       *activation,
       entry->name = name;
       entry->exec = exec;
       entry->user = user;
+      /* ownership has been transferred to entry, do not free separately */
+      name = NULL;
+      exec = NULL;
+      user = NULL;
+      systemd_service = NULL;
+
       if (!_dbus_hash_table_insert_string (activation->entries,
                                            entry->name, bus_activation_entry_ref(entry)))
         {