[libnotify/fix-electron-crash] notification: Fix Electron crash




commit 168c8c2d64c8cb2a8795bf8eb24435e38a0e6b08
Author: Logan Rathbone <poprocks gmail com>
Date:   Wed May 4 16:23:03 2022 -0400

    notification: Fix Electron crash
    
    - Starting with d0778595, we access the Notification object after the
      NotifyActionCallback; some clients (eg, Electron) have historically
      freed the object at the end of the NotifyActionCallback. They probably
      should not have been doing so, but this hotfix adds an additional ref
      before and after the callback so that we don't break existing code.
    - Fixes #25

 libnotify/notification.c | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/libnotify/notification.c b/libnotify/notification.c
index 482ee3e..af63e33 100644
--- a/libnotify/notification.c
+++ b/libnotify/notification.c
@@ -740,11 +740,18 @@ proxy_g_signal_cb (GDBusProxy *proxy,
                         }
                 } else {
                         notification->priv->activating = TRUE;
+
+                        /* nb: some clients have assumed it is safe to free the Notification
+                         * object at the end of their NotifyActionCallback, so we take an
+                         * extra ref to work around that. */
+                        g_object_ref (notification);
                         pair->cb (notification, (char *) action, pair->user_data);
                         notification->priv->activating = FALSE;
 
                         g_free (notification->priv->activation_token);
                         notification->priv->activation_token = NULL;
+
+                        g_object_unref (notification);
                 }
         } else if (g_strcmp0 (signal_name, "ActivationToken") == 0 &&
                    g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(us)"))) {


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