seat: fix closing dummy sessions
authorDavid Herrmann <dh.herrmann@googlemail.com>
Tue, 23 Oct 2012 11:18:42 +0000 (13:18 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Tue, 23 Oct 2012 11:18:42 +0000 (13:18 +0200)
We must reset the "dummy" pointer when unregistering dummy sessions,
otherwise, we will get NULL pointer derefs.
This also prevents keyboard-input from closing dummy sessions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/kmscon_seat.c

index 5cc127e..c48f1d8 100644 (file)
@@ -338,6 +338,9 @@ static void seat_input_event(struct uterm_input *input,
        if (conf_grab_matches(seat->conf->grab_session_close,
                              ev->mods, ev->num_syms, ev->keysyms)) {
                ev->handled = true;
+               if (seat->cur_sess == seat->dummy)
+                       return;
+
                kmscon_session_unregister(seat->cur_sess);
                return;
        }
@@ -648,6 +651,9 @@ void kmscon_session_unregister(struct kmscon_session *sess)
 
        log_debug("unregister session %p", sess);
 
+       if (sess->seat->dummy == sess)
+               sess->seat->dummy = NULL;
+
        session_deactivate(sess);
        shl_dlist_unlink(&sess->list);
        --sess->seat->session_count;