From 5e89ba5a742ecbd5910a2bb4e963159ce076ae39 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 12 Nov 2019 20:59:40 +0000 Subject: [PATCH] gsignal: Clarify signal detail format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The format has never previously been specified. It can be anything, but for sanity’s sake disallow empty strings. Signed-off-by: Philip Withnall Helps: #358 --- gobject/gsignal.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gobject/gsignal.c b/gobject/gsignal.c index 43949c580..579eb4846 100644 --- a/gobject/gsignal.c +++ b/gobject/gsignal.c @@ -98,6 +98,10 @@ * detail part of the signal specification upon connection) serves as a * wildcard and matches any detail argument passed in to emission. * + * While the @detail argument is typically used to pass an object property name + * (as with #GObject::notify), no specific format is mandated for the detail + * string, other than that it must be non-empty. + * * ## Memory management of signal handlers # {#signal-memory-management} * * If you are connecting handlers to signals and using a #GObject instance as @@ -1158,6 +1162,9 @@ signal_parse_name (const gchar *name, gchar buffer[32]; guint l = colon - name; + if (colon[2] == '\0') + return 0; + if (l < 32) { memcpy (buffer, name, l); @@ -1175,7 +1182,7 @@ signal_parse_name (const gchar *name, } if (signal_id && detail_p) - *detail_p = colon[2] ? (force_quark ? g_quark_from_string : g_quark_try_string) (colon + 2) : 0; + *detail_p = (force_quark ? g_quark_from_string : g_quark_try_string) (colon + 2); } else signal_id = 0;