Commit 34747107fe38baac55f1972f4fb1c051510b812e

Philipp Wiesemann 2017-05-06T21:46:00

mir: Fixed memory leak if system cursor id is unknown.

diff --git a/src/video/mir/SDL_mirmouse.c b/src/video/mir/SDL_mirmouse.c
index 40f7744..5d00dc0 100644
--- a/src/video/mir/SDL_mirmouse.c
+++ b/src/video/mir/SDL_mirmouse.c
@@ -139,15 +139,9 @@ static SDL_Cursor*
 MIR_CreateSystemCursor(SDL_SystemCursor id)
 {
     char const* cursor_name = NULL;
-    SDL_Cursor* cursor      = MIR_CreateDefaultCursor();
+    SDL_Cursor* cursor;
     MIR_Cursor* mir_cursor;
 
-    if (!cursor) {
-        return NULL;
-    }
-
-    mir_cursor = (MIR_Cursor*)cursor->driverdata;
-
     switch(id) {
         case SDL_SYSTEM_CURSOR_ARROW:
             cursor_name = MIR_mir_arrow_cursor_name;
@@ -192,6 +186,12 @@ MIR_CreateSystemCursor(SDL_SystemCursor id)
             return NULL;
     }
 
+    cursor = MIR_CreateDefaultCursor();
+    if (!cursor) {
+        return NULL;
+    }
+
+    mir_cursor = (MIR_Cursor*)cursor->driverdata;
     mir_cursor->name = cursor_name;
 
     return cursor;