Raspberry: Fixed crash if memory allocation for cursor failed.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Thu, 03 Mar 2016 20:12:51 +0100
changeset 10101 075d70623646
parent 10100 a18ec339c8d3
child 10102 11b490897d27
Raspberry: Fixed crash if memory allocation for cursor failed.
src/video/raspberry/SDL_rpimouse.c
--- a/src/video/raspberry/SDL_rpimouse.c	Thu Mar 03 20:11:43 2016 +0100
+++ b/src/video/raspberry/SDL_rpimouse.c	Thu Mar 03 20:12:51 2016 +0100
@@ -70,7 +70,16 @@
     SDL_assert(surface->pitch == surface->w * 4);
     
     cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
+    if (cursor == NULL) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
     curdata = (RPI_CursorData *) SDL_calloc(1, sizeof(*curdata));
+    if (curdata == NULL) {
+        SDL_OutOfMemory();
+        SDL_free(cursor);
+        return NULL;
+    }
 
     curdata->hot_x = hot_x;
     curdata->hot_y = hot_y;