[glib] fdo notification: Avoid a double free



commit 1920b550db823387ebea755c2bfd3a7393f90a46
Author: Timm Bäder <mail baedert org>
Date:   Thu Jan 19 08:18:59 2017 +0100

    fdo notification: Avoid a double free
    
    We're first getting the notification by its notify_id, but activating
    the action afterwards could redraw it, leading to a dangling pointer.
    Fix this by simply searching the list of active notifications again
    after activating the action.

 gio/gfdonotificationbackend.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gio/gfdonotificationbackend.c b/gio/gfdonotificationbackend.c
index 9a39d75..4261370 100644
--- a/gio/gfdonotificationbackend.c
+++ b/gio/gfdonotificationbackend.c
@@ -178,8 +178,13 @@ notify_signal (GDBusConnection *connection,
         }
     }
 
-  backend->notifications = g_slist_remove (backend->notifications, n);
-  freedesktop_notification_free (n);
+  /* Get the notification again in case the action redrew it */
+  n = g_fdo_notification_backend_find_notification_by_notify_id (backend, id);
+  if (n != NULL)
+    {
+      backend->notifications = g_slist_remove (backend->notifications, n);
+      freedesktop_notification_free (n);
+    }
 }
 
 /* Converts a GNotificationPriority to an urgency level as defined by


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]