From ab8be04310363e3bbe2383d7af01ab22cca0ee2e Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Wed, 2 Mar 2016 20:25:09 +0100 Subject: [PATCH] Wayland: Fixed crash if allocating memory for cursor failed. Also added missing error message if first allocation failed. --- src/video/wayland/SDL_waylandmouse.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c index b810f7784..ea71f095a 100644 --- a/src/video/wayland/SDL_waylandmouse.c +++ b/src/video/wayland/SDL_waylandmouse.c @@ -159,6 +159,11 @@ Wayland_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) SDL_VideoDevice *vd = SDL_GetVideoDevice (); SDL_VideoData *wd = (SDL_VideoData *) vd->driverdata; Wayland_CursorData *data = calloc (1, sizeof (Wayland_CursorData)); + if (!data) { + SDL_OutOfMemory(); + free(cursor); + return NULL; + } cursor->driverdata = (void *) data; /* Assume ARGB8888 */ @@ -187,6 +192,8 @@ Wayland_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) data->hot_y = hot_y; data->w = surface->w; data->h = surface->h; + } else { + SDL_OutOfMemory(); } return cursor; @@ -200,6 +207,11 @@ CreateCursorFromWlCursor(SDL_VideoData *d, struct wl_cursor *wlcursor) cursor = calloc(1, sizeof (*cursor)); if (cursor) { Wayland_CursorData *data = calloc (1, sizeof (Wayland_CursorData)); + if (!data) { + SDL_OutOfMemory(); + free(cursor); + return NULL; + } cursor->driverdata = (void *) data; data->buffer = WAYLAND_wl_cursor_image_get_buffer(wlcursor->images[0]);