Commit 72fdf62980574e517fc95ab93ed3ee07fc0e0f6d

Philipp Wiesemann 2017-03-04T23:05:32

Mir: Fixed crash if creating default cursor failed. Found by Cppcheck.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/video/mir/SDL_mirmouse.c b/src/video/mir/SDL_mirmouse.c
index 5a2a303..40f7744 100644
--- a/src/video/mir/SDL_mirmouse.c
+++ b/src/video/mir/SDL_mirmouse.c
@@ -140,12 +140,14 @@ MIR_CreateSystemCursor(SDL_SystemCursor id)
 {
     char const* cursor_name = NULL;
     SDL_Cursor* cursor      = MIR_CreateDefaultCursor();
-    MIR_Cursor* mir_cursor  = (MIR_Cursor*)cursor->driverdata;
+    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;