From 8d5701cb5446904d476b9304d7a8a82f238b6849 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Thu, 3 Mar 2016 20:12:51 +0100 Subject: [PATCH] Raspberry: Fixed crash if memory allocation for cursor failed. --- src/video/raspberry/SDL_rpimouse.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c index 0d1482c04..065f2097c 100644 --- a/src/video/raspberry/SDL_rpimouse.c +++ b/src/video/raspberry/SDL_rpimouse.c @@ -70,7 +70,16 @@ RPI_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) 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;