Skip to content

Commit

Permalink
Wayland: Fixed crash if allocating memory for cursor failed.
Browse files Browse the repository at this point in the history
Also added missing error message if first allocation failed.
  • Loading branch information
philippwiesemann committed Mar 2, 2016
1 parent e8b4368 commit ab8be04
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/video/wayland/SDL_waylandmouse.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand All @@ -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]);
Expand Down

0 comments on commit ab8be04

Please sign in to comment.