chiark / gitweb /
dbus-manager: fix a fatal dbus abort in bus_manager_message_handler()
[elogind.git] / src / core / dbus-manager.c
index 8a6449493a709544741e3261fcad964bbf7fd065..3cf3e90a3659d9fc2b49dc440889c9b3c8fbd6ae 100644 (file)
@@ -352,17 +352,21 @@ static int bus_manager_set_log_target(DBusMessageIter *i, const char *property,
 }
 
 static int bus_manager_append_log_level(DBusMessageIter *i, const char *property, void *data) {
-        const char *t;
+        char *t;
+        int r;
 
         assert(i);
         assert(property);
 
-        t = log_level_to_string(log_get_max_level());
+        r = log_level_to_string_alloc(log_get_max_level(), &t);
+        if (r < 0)
+                return r;
 
         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t))
-                return -ENOMEM;
+                r = -ENOMEM;
 
-        return 0;
+        free(t);
+        return r;
 }
 
 static int bus_manager_set_log_level(DBusMessageIter *i, const char *property, void *data) {
@@ -641,7 +645,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                         goto oom;
 
                 path = unit_dbus_path(u);
-                if (!reply)
+                if (!path)
                         goto oom;
 
                 if (!dbus_message_append_args(
@@ -1432,7 +1436,6 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                 r = unit_file_get_list(m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, h);
                 if (r < 0) {
                         unit_file_list_free(h);
-                        dbus_message_unref(reply);
                         return bus_send_error_reply(connection, message, NULL, r);
                 }