Added three missing checks for return values of SDL_calloc().
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Fri, 26 Dec 2014 20:11:28 +0100
changeset 9298 98279bdf2230
parent 9297 b4c74c050628
child 9299 1d3bee66d518
Added three missing checks for return values of SDL_calloc().
src/video/emscripten/SDL_emscriptenmouse.c
--- a/src/video/emscripten/SDL_emscriptenmouse.c	Wed Dec 24 11:33:42 2014 -0500
+++ b/src/video/emscripten/SDL_emscriptenmouse.c	Fri Dec 26 20:11:28 2014 +0100
@@ -42,6 +42,11 @@
     cursor = SDL_calloc(1, sizeof(SDL_Cursor));
     if (cursor) {
         curdata = (Emscripten_CursorData *) SDL_calloc(1, sizeof(*curdata));
+        if (!curdata) {
+            SDL_OutOfMemory();
+            SDL_free(cursor);
+            return NULL;
+        }
 
         curdata->system_cursor = "default";
         cursor->driverdata = curdata;
@@ -108,7 +113,16 @@
     }
 
     cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
+    if (!cursor) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
     curdata = (Emscripten_CursorData *) SDL_calloc(1, sizeof(*curdata));
+    if (!curdata) {
+        SDL_OutOfMemory();
+        SDL_free(cursor);
+        return NULL;
+    }
 
     curdata->system_cursor = cursor_name;
     cursor->driverdata = curdata;