Wayland: Fixed crash if allocating memory for cursor failed.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 02 Mar 2016 20:25:09 +0100
changeset 10098 91b34fbbb88e
parent 10097 06085b9c73ef
child 10099 c7932bb6dcee
Wayland: Fixed crash if allocating memory for cursor failed. Also added missing error message if first allocation failed.
src/video/wayland/SDL_waylandmouse.c
--- a/src/video/wayland/SDL_waylandmouse.c	Wed Mar 02 20:24:43 2016 +0100
+++ b/src/video/wayland/SDL_waylandmouse.c	Wed Mar 02 20:25:09 2016 +0100
@@ -159,6 +159,11 @@
         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 @@
         data->hot_y = hot_y;
         data->w = surface->w;
         data->h = surface->h;
+    } else {
+        SDL_OutOfMemory();
     }
 
     return cursor;
@@ -200,6 +207,11 @@
     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]);