daemon: fix memleak in org.freedesktop.UPower.Wakeups.GetData

up_wakeups_get_cmdline returns allocated memory and
up_wakeup_item_set_cmdline duplicates it. Therefore free the former
after setting it on the item.

https://bugs.freedesktop.org/show_bug.cgi?id=82659
This commit is contained in:
Peter Wu 2014-11-17 22:32:42 +01:00 committed by Richard Hughes
parent d1971e4d16
commit 73927044cb

View file

@ -469,6 +469,7 @@ up_wakeups_poll_userspace_cb (UpWakeups *wakeups)
guint pid;
guint interrupts;
gfloat interval = 5.0f;
gchar *cmdline;
g_debug ("event");
@ -546,7 +547,9 @@ up_wakeups_poll_userspace_cb (UpWakeups *wakeups)
up_wakeup_item_set_is_userspace (item, FALSE);
} else {
/* try to get a better command line */
up_wakeup_item_set_cmdline (item, up_wakeups_get_cmdline (pid));
cmdline = up_wakeups_get_cmdline (pid);
up_wakeup_item_set_cmdline (item, cmdline);
g_free (cmdline);
if (up_wakeup_item_get_cmdline (item) == NULL ||
up_wakeup_item_get_cmdline (item)[0] == '\0')
up_wakeup_item_set_cmdline (item, string);