diff options
author | Max Kellermann <max@duempel.org> | 2008-09-17 12:08:06 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-17 12:08:06 +0200 |
commit | 7cc4ce52e00040bdb96b2a8dee9f19d0541100c5 (patch) | |
tree | 0ae6bf053f226cc3b118a79788a8eb90c6e98409 | |
parent | 2cbb38814a0e883563e743031dbde58b83b90749 (diff) | |
download | mpd-7cc4ce52e00040bdb96b2a8dee9f19d0541100c5.tar.gz mpd-7cc4ce52e00040bdb96b2a8dee9f19d0541100c5.tar.xz mpd-7cc4ce52e00040bdb96b2a8dee9f19d0541100c5.zip |
screen: return early in switch_screen_mode() on error
When the selected screen does not exist, return before calling
close().
-rw-r--r-- | src/screen.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/screen.c b/src/screen.c index a55b2cf82..0c59d6940 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 */ |