diff options
author | Giedrius Statkevičius <[email protected]> | 2015-10-19 16:45:43 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2015-10-19 17:30:39 +0300 |
commit | 75a97c0721b36ee3aafb33b0daed60a0348072f2 (patch) | |
tree | b0a78e8af670c86445c272b914e09ffb9dbe0cfa | |
parent | 96949654be3fd993c5aa1a786036161f16070077 (diff) | |
download | mate-notification-daemon-75a97c0721b36ee3aafb33b0daed60a0348072f2.tar.bz2 mate-notification-daemon-75a97c0721b36ee3aafb33b0daed60a0348072f2.tar.xz |
daemon: fix memory leak in on_popup_location_changed()
Don't forget to free the result of g_settings_get_string(). Also, change
`slocation' to proper type gchar* for storing results of
g_settings_get_string(). Furthermore, this allows to use that pointer in free()
without any casting.
-rw-r--r-- | src/daemon/daemon.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index a412ed1..e82ae90 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -127,7 +127,7 @@ static void _close_notification(NotifyDaemon* daemon, guint id, gboolean hide_no static GdkFilterReturn _notify_x11_filter(GdkXEvent* xevent, GdkEvent* event, NotifyDaemon* daemon); static void _emit_closed_signal(GtkWindow* nw, NotifydClosedReason reason); static void _action_invoked_cb(GtkWindow* nw, const char* key); -static NotifyStackLocation get_stack_location_from_string(const char* slocation); +static NotifyStackLocation get_stack_location_from_string(const gchar *slocation); static void sync_notification_position(NotifyDaemon* daemon, GtkWindow* nw, Window source); static void monitor_notification_source_windows(NotifyDaemon* daemon, NotifyTimeout* nt, Window source); @@ -359,7 +359,7 @@ static void create_screens(NotifyDaemon* daemon) static void on_popup_location_changed(GSettings *settings, gchar *key, NotifyDaemon* daemon) { NotifyStackLocation stack_location; - const char* slocation; + gchar *slocation; int i; slocation = g_settings_get_string(daemon->gsettings, key); @@ -376,6 +376,7 @@ static void on_popup_location_changed(GSettings *settings, gchar *key, NotifyDae } daemon->priv->stack_location = stack_location; + g_free(slocation); #if GTK_CHECK_VERSION (3, 8, 0) NotifyScreen *nscreen; @@ -526,7 +527,7 @@ static void notify_daemon_finalize(GObject* object) G_OBJECT_CLASS(notify_daemon_parent_class)->finalize(object); } -static NotifyStackLocation get_stack_location_from_string(const char* slocation) +static NotifyStackLocation get_stack_location_from_string(const gchar *slocation) { NotifyStackLocation stack_location = NOTIFY_STACK_LOCATION_DEFAULT; |