Skip to content

Commit

Permalink
Mir: Fixed crash if allocating memory for cursor failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
philippwiesemann committed Feb 22, 2016
1 parent 697984d commit 92209c2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/video/mir/SDL_mirmouse.c
Expand Up @@ -59,6 +59,8 @@ MIR_CreateDefaultCursor()
}
else {
SDL_OutOfMemory();
SDL_free(cursor);
cursor = NULL;
}
}
else {
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 92209c2

Please sign in to comment.