Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mir: Fixed memory leak if system cursor id is unknown.
  • Loading branch information
philippwiesemann committed May 6, 2017
1 parent 34d9c52 commit 3474710
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/video/mir/SDL_mirmouse.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3474710

Please sign in to comment.