From 7cc4ce52e00040bdb96b2a8dee9f19d0541100c5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 17 Sep 2008 12:08:06 +0200 Subject: [PATCH] screen: return early in switch_screen_mode() on error When the selected screen does not exist, return before calling close(). --- src/screen.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 */ -- 2.30.2