[Commits] SDL: mir: Fixed memory leak if system cursor id is unknown.

libsdl.org revision control commits-owner at libsdl.org
Sat May 6 12:53:34 PDT 2017


details:   https://hg.libsdl.org/SDL/rev/b3c950a6fb09
changeset: 10990:b3c950a6fb09
user:      Philipp Wiesemann <philipp.wiesemann at arcor.de>
date:      Sat May 06 21:46:00 2017 +0200
description:
mir: Fixed memory leak if system cursor id is unknown.

diffstat:

 src/video/mir/SDL_mirmouse.c |  14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diffs (33 lines):

diff -r 111b5e23c6a3 -r b3c950a6fb09 src/video/mir/SDL_mirmouse.c
--- a/src/video/mir/SDL_mirmouse.c	Sat May 06 21:45:43 2017 +0200
+++ b/src/video/mir/SDL_mirmouse.c	Sat May 06 21:46:00 2017 +0200
@@ -139,15 +139,9 @@
 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 @@
             return NULL;
     }
 
+    cursor = MIR_CreateDefaultCursor();
+    if (!cursor) {
+        return NULL;
+    }
+
+    mir_cursor = (MIR_Cursor*)cursor->driverdata;
     mir_cursor->name = cursor_name;
 
     return cursor;


More information about the commits mailing list