[Commits] SDL: Raspberry: Fixed crash if memory allocation for cursor failed.

libsdl.org revision control commits-owner at libsdl.org
Thu Mar 3 11:21:05 PST 2016


details:   https://hg.libsdl.org/SDL/rev/075d70623646
changeset: 10101:075d70623646
user:      Philipp Wiesemann <philipp.wiesemann at arcor.de>
date:      Thu Mar 03 20:12:51 2016 +0100
description:
Raspberry: Fixed crash if memory allocation for cursor failed.

diffstat:

 src/video/raspberry/SDL_rpimouse.c |  9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diffs (20 lines):

diff -r a18ec339c8d3 -r 075d70623646 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;


More information about the commits mailing list