Code

screen: return early in switch_screen_mode() on error
authorMax Kellermann <max@duempel.org>
Wed, 17 Sep 2008 10:08:06 +0000 (12:08 +0200)
committerMax Kellermann <max@duempel.org>
Wed, 17 Sep 2008 10:08:06 +0000 (12:08 +0200)
When the selected screen does not exist, return before calling
close().

src/screen.c

index a55b2cf825e3ed3f6218ecf295d86f1f61f59b27..0c59d6940ea36d82024c828885c443ac003aebea 100644 (file)
@@ -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 */