chiark / gitweb /
login: fix memory-leak on DropController()
authorDavid Herrmann <dh.herrmann@gmail.com>
Fri, 22 Aug 2014 12:57:11 +0000 (14:57 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Wed, 27 Aug 2014 16:42:28 +0000 (18:42 +0200)
Our bus-name watch helpers only remove a bus-name if it's not a
controller, anymore. If we call manager_drop_busname() before
unregistering the controller, the busname will not be dropped. Therefore,
first drop the controller, then drop the bus-name.

src/login/logind-session.c

index 136bbce78e5b4a95f12eb171ae218970372f4bc5..0c6e425603830f2bf74bef83523bc7fe1146de48 100644 (file)
@@ -1061,11 +1061,13 @@ bool session_is_controller(Session *s, const char *sender) {
 
 static void session_swap_controller(Session *s, char *name) {
         SessionDevice *sd;
+        char *c;
 
         if (s->controller) {
-                manager_drop_busname(s->manager, s->controller);
-                free(s->controller);
+                c = s->controller;
                 s->controller = NULL;
+                manager_drop_busname(s->manager, c);
+                free(c);
 
                 /* Drop all devices as they're now unused. Do that after the
                  * controller is released to avoid sending out useles