From 34747107fe38baac55f1972f4fb1c051510b812e Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Sat, 6 May 2017 21:46:00 +0200 Subject: [PATCH] mir: Fixed memory leak if system cursor id is unknown. --- src/video/mir/SDL_mirmouse.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/video/mir/SDL_mirmouse.c b/src/video/mir/SDL_mirmouse.c index 40f774428..5d00dc0e2 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;