[glib: 4/7] gdbusdaemon: Add sanity checks on name refcounting



commit d99653f6fec1bede269887fd67ca445f50cc2847
Author: Philip Withnall <withnall endlessm com>
Date:   Thu Sep 5 14:15:19 2019 +0100

    gdbusdaemon: Add sanity checks on name refcounting
    
    This should make the code a bit easier to reason about, and squash some
    static analysis warnings.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Helps: #1767

 gio/gdbusdaemon.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/gio/gdbusdaemon.c b/gio/gdbusdaemon.c
index 0d5058f70..e03d7aabd 100644
--- a/gio/gdbusdaemon.c
+++ b/gio/gdbusdaemon.c
@@ -170,6 +170,7 @@ name_new (GDBusDaemon *daemon, const char *str)
 static Name *
 name_ref (Name *name)
 {
+  g_assert (name->refcount > 0);
   name->refcount++;
   return name;
 }
@@ -177,6 +178,7 @@ name_ref (Name *name)
 static void
 name_unref (Name *name)
 {
+  g_assert (name->refcount > 0);
   if (--name->refcount == 0)
     {
       g_hash_table_remove (name->daemon->names, name->name);


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