From 29e7f0def1f713bfc57231f766eeeb71d3256f0e Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Mon, 19 May 2014 18:38:16 -0700 Subject: [PATCH] Fix null pointer trying to alt-tab without windows --- userspace/gui/core/panel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/userspace/gui/core/panel.c b/userspace/gui/core/panel.c index 8cf7eba3..f0794eb7 100644 --- a/userspace/gui/core/panel.c +++ b/userspace/gui/core/panel.c @@ -223,6 +223,8 @@ static void handle_key_event(struct yutani_msg_key_event * ke) { struct window_ad * ad = ads_by_z[new_focused]; + if (!ad) return; + yutani_focus_window(yctx, ad->wid); was_tabbing = 0; new_focused = -1; @@ -241,6 +243,8 @@ static void handle_key_event(struct yutani_msg_key_event * ke) { int direction = (ke->event.modifiers & KEY_MOD_LEFT_SHIFT) ? 1 : -1; + if (window_list->length < 1) return; + if (was_tabbing) { new_focused = new_focused + direction; } else { @@ -257,7 +261,7 @@ static void handle_key_event(struct yutani_msg_key_event * ke) { if (new_focused < 0) { new_focused = 0; - for (int i = 0; i < 18; i++) { + for (int i = 0; i < MAX_WINDOW_COUNT; i++) { if (ads_by_z[i+1] == NULL) { new_focused = i; break;