summaryrefslogtreecommitdiff
path: root/cursor
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2014-01-10 14:33:36 -0800
committerKristian Høgsberg <krh@bitplanet.net>2014-01-15 10:46:09 -0800
commitd6c6f2977de84d54395def96e18a448ae68bf711 (patch)
treea5a7c335b69ed4e413280eae12010d1e75900008 /cursor
parent7d96da1e651a046e8f688da1aebf45e52aed9096 (diff)
cursor: check for memory allocation errors
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
Diffstat (limited to 'cursor')
-rw-r--r--cursor/wayland-cursor.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/cursor/wayland-cursor.c b/cursor/wayland-cursor.c
index e41b00f..b16f530 100644
--- a/cursor/wayland-cursor.c
+++ b/cursor/wayland-cursor.c
@@ -261,6 +261,11 @@ load_default_theme(struct wl_cursor_theme *theme)
theme->cursor_count = ARRAY_LENGTH(cursor_metadata);
theme->cursors = malloc(theme->cursor_count * sizeof(*theme->cursors));
+ if (theme->cursors == NULL) {
+ theme->cursor_count = 0;
+ return;
+ }
+
for (i = 0; i < theme->cursor_count; ++i) {
theme->cursors[i] =
wl_cursor_create_from_data(&cursor_metadata[i], theme);
@@ -295,6 +300,8 @@ wl_cursor_create_from_xcursor_images(XcursorImages *images,
for (i = 0; i < images->nimage; i++) {
image = malloc(sizeof *image);
+ if (image == NULL)
+ break;
image->theme = theme;
image->buffer = NULL;
@@ -349,7 +356,12 @@ load_callback(XcursorImages *images, void *data)
realloc(theme->cursors,
theme->cursor_count * sizeof theme->cursors[0]);
- theme->cursors[theme->cursor_count - 1] = cursor;
+ if (theme->cursors == NULL) {
+ theme->cursor_count--;
+ free(cursor);
+ } else {
+ theme->cursors[theme->cursor_count - 1] = cursor;
+ }
}
XcursorImagesDestroy(images);