chiark / gitweb /
bus: add assert to check that we're not freeing a static structure
[elogind.git] / src / libsystemd / sd-bus / sd-bus.c
index 78e91b96541809ef35e13d0b5edf0ac55ab8c890..bc4376fb510533478871854717157729fa04c76c 100644 (file)
@@ -142,6 +142,7 @@ static void bus_free(sd_bus *b) {
         hashmap_free_free(b->reply_callbacks);
         prioq_free(b->reply_callbacks_prioq);
 
+        assert(b->match_callbacks.type == BUS_MATCH_ROOT);
         bus_match_free(&b->match_callbacks);
 
         hashmap_free_free(b->vtable_methods);
@@ -349,8 +350,6 @@ static int hello_callback(sd_bus *bus, sd_bus_message *reply, void *userdata, sd
         assert(reply);
 
         r = sd_bus_message_get_errno(reply);
-        if (r < 0)
-                return r;
         if (r > 0)
                 return -r;
 
@@ -1756,7 +1755,7 @@ _public_ int sd_bus_call_async(
         if (!BUS_IS_OPEN(bus->state))
                 return -ENOTCONN;
 
-        r = hashmap_ensure_allocated(&bus->reply_callbacks, uint64_hash_func, uint64_compare_func);
+        r = hashmap_ensure_allocated(&bus->reply_callbacks, &uint64_hash_ops);
         if (r < 0)
                 return r;
 
@@ -3339,8 +3338,10 @@ _public_ int sd_bus_get_peer_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **re
         }
 
         r = bus_creds_add_more(c, mask, pid, 0);
-        if (r < 0)
+        if (r < 0) {
+                sd_bus_creds_unref(c);
                 return r;
+        }
 
         *ret = c;
         return 0;