[glib: 2/3] gsignal: Do not try to lookup the signal id and work on unlocked node




commit 42d52033db652f38015aabb3c1b5a0a103f65aea
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Fri Jul 15 16:09:14 2022 +0200

    gsignal: Do not try to lookup the signal id and work on unlocked node
    
    In g_signal_parse_name we were looking up for the signal from the name
    keeping the mutex locked, but we then retrieved and checked the node
    data without keeping the lock, so with another thread potentially
    changing that.

 gobject/gsignal.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gobject/gsignal.c b/gobject/gsignal.c
index 8b4fbfea3d..32453bc519 100644
--- a/gobject/gsignal.c
+++ b/gobject/gsignal.c
@@ -1216,12 +1216,17 @@ g_signal_parse_name (const gchar *detailed_signal,
   
   SIGNAL_LOCK ();
   signal_id = signal_parse_name (detailed_signal, itype, &detail, force_detail_quark);
-  SIGNAL_UNLOCK ();
 
   node = signal_id ? LOOKUP_SIGNAL_NODE (signal_id) : NULL;
+
   if (!node || node->destroyed ||
       (detail && !(node->flags & G_SIGNAL_DETAILED)))
-    return FALSE;
+    {
+      SIGNAL_UNLOCK ();
+      return FALSE;
+    }
+
+  SIGNAL_UNLOCK ();
 
   if (signal_id_p)
     *signal_id_p = signal_id;


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