From: Max Kellermann Date: Wed, 17 Sep 2008 10:08:06 +0000 (+0200) Subject: screen: return early in switch_screen_mode() on error X-Git-Tag: v0.12_alpha1~274 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7cc4ce52e00040bdb96b2a8dee9f19d0541100c5;p=ncmpc.git screen: return early in switch_screen_mode() on error When the selected screen does not exist, return before calling close(). --- diff --git a/src/screen.c b/src/screen.c index a55b2cf..0c59d69 100644 --- a/src/screen.c +++ b/src/screen.c @@ -140,18 +140,18 @@ switch_screen_mode(gint id, mpdclient_t *c) if( id == screens[screen.mode].id ) return; + new_mode = lookup_mode(id); + if (new_mode < 0) + return; + /* close the old mode */ if (mode_fn->close != NULL) mode_fn->close(); /* get functions for the new mode */ - new_mode = lookup_mode(id); - if (new_mode >= 0) { - D("switch_screen(%s)\n", screens[new_mode].name ); - mode_fn = screens[new_mode].functions; - screen.mode = new_mode; - } - + D("switch_screen(%s)\n", screens[new_mode].name ); + mode_fn = screens[new_mode].functions; + screen.mode = new_mode; screen.painted = 0; /* open the new mode */