[glib: 2/5] gdbusdaemon: Add an assertion to help static analysis of refcounts
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/5] gdbusdaemon: Add an assertion to help static analysis of refcounts
- Date: Tue, 10 May 2022 16:30:20 +0000 (UTC)
commit 77679787255cc1d7cc881766a82f8fdd051507e6
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue May 10 16:17:38 2022 +0100
gdbusdaemon: Add an assertion to help static analysis of refcounts
This should fix a scan-build warning about the final `name_unref()` here
being a use-after-free.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
gio/gdbusdaemon.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gio/gdbusdaemon.c b/gio/gdbusdaemon.c
index 5dfe62cd33..2bb7b8816e 100644
--- a/gio/gdbusdaemon.c
+++ b/gio/gdbusdaemon.c
@@ -874,7 +874,11 @@ client_free (Client *client)
name_ref (name);
if (name->owner && name->owner->client == client)
- name_release_owner (name);
+ {
+ /* Help static analysers with the refcount at this point. */
+ g_assert (name->refcount >= 2);
+ name_release_owner (name);
+ }
name_unqueue_owner (name, client);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]