From 92209c260d5b36db12bbdf7f4a0f669806c11468 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Mon, 22 Feb 2016 19:00:22 +0100 Subject: [PATCH] Mir: Fixed crash if allocating memory for cursor failed. --- src/video/mir/SDL_mirmouse.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/video/mir/SDL_mirmouse.c b/src/video/mir/SDL_mirmouse.c index 425588e1d..7a89f72e2 100644 --- a/src/video/mir/SDL_mirmouse.c +++ b/src/video/mir/SDL_mirmouse.c @@ -59,6 +59,8 @@ MIR_CreateDefaultCursor() } else { SDL_OutOfMemory(); + SDL_free(cursor); + cursor = NULL; } } else { @@ -108,7 +110,13 @@ MIR_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y) MIR_Data* mir_data = (MIR_Data*)SDL_GetVideoDevice()->driverdata; 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; stream = MIR_mir_connection_create_buffer_stream_sync(mir_data->connection, s_w, s_h, mir_data->pixel_format, @@ -132,6 +140,10 @@ MIR_CreateSystemCursor(SDL_SystemCursor id) MirCursorConfiguration* conf; SDL_Cursor* cursor = MIR_CreateDefaultCursor(); + if (!cursor) { + return NULL; + } + switch(id) { case SDL_SYSTEM_CURSOR_ARROW: cursor_name = MIR_mir_arrow_cursor_name;