chiark / gitweb /
bus: avoid using m->kdbus after freeing it
authorPhilippe De Swert <philippedeswert@gmail.com>
Wed, 10 Sep 2014 09:20:38 +0000 (12:20 +0300)
committerDavid Herrmann <dh.herrmann@gmail.com>
Thu, 11 Sep 2014 15:09:50 +0000 (17:09 +0200)
m->kdbus could be freed before it is released. Changing the
order fixes the issue.

Found with Coverity. Fixes: CID#1237798

src/libsystemd/sd-bus/bus-message.c

index d00455a..bfb14fc 100644 (file)
@@ -127,9 +127,6 @@ static void message_free(sd_bus_message *m) {
 
         message_reset_parts(m);
 
-        if (m->free_kdbus)
-                free(m->kdbus);
-
         if (m->release_kdbus) {
                 uint64_t off;
 
@@ -137,6 +134,9 @@ static void message_free(sd_bus_message *m) {
                 ioctl(m->bus->input_fd, KDBUS_CMD_FREE, &off);
         }
 
+        if (m->free_kdbus)
+                free(m->kdbus);
+
         sd_bus_unref(m->bus);
 
         if (m->free_fds) {