[glib: 1/2] gsignal: Change signal instance ref semantics under static analysis
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] gsignal: Change signal instance ref semantics under static analysis
- Date: Tue, 21 Jun 2022 12:54:44 +0000 (UTC)
commit 95d548ab03aab59687a3bafd4c9863559d7824ea
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue Jun 21 12:16:02 2022 +0100
gsignal: Change signal instance ref semantics under static analysis
As with commit 0932f71460a93a, which did this for refs/unrefs of the
object in `g_object_notify()`, we need to do a similar thing for
refs/unrefs of the instance with `g_signal_emit()`, for all the same
reasons.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
gobject/gsignal.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
diff --git a/gobject/gsignal.c b/gobject/gsignal.c
index ddd23fb738..aeb60b2ba0 100644
--- a/gobject/gsignal.c
+++ b/gobject/gsignal.c
@@ -3402,7 +3402,16 @@ g_signal_emit_valist (gpointer instance,
if (closure != NULL)
{
+ /*
+ * Coverity doesn’t understand the paired ref/unref here and seems
+ * to ignore the ref, thus reports every call to g_signal_emit()
+ * as causing a double-free. That’s incorrect, but I can’t get a
+ * model file to work for avoiding the false positives, so instead
+ * comment out the ref/unref when doing static analysis.
+ */
+#ifndef __COVERITY__
g_object_ref (instance);
+#endif
_g_closure_invoke_va (closure,
return_accu,
instance,
@@ -3452,8 +3461,11 @@ g_signal_emit_valist (gpointer instance,
TRACE(GOBJECT_SIGNAL_EMIT_END(signal_id, detail, instance, instance_type));
+ /* See comment above paired ref above */
+#ifndef __COVERITY__
if (closure != NULL)
g_object_unref (instance);
+#endif
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]