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
This commit is contained in:
Philip Withnall 2019-09-05 14:15:19 +01:00
parent df647a583d
commit d99653f6fe

View File

@ -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);