This patch adds checks for themes and cursors returned by wl_cursor functions.
---
 clients/simple-egl.c     | 10 ++++++++++
 clients/window.c         |  4 ++++
 src/compositor-wayland.c |  7 ++++++-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index a6deff6..410e3ab 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -501,6 +501,8 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
        else if (cursor) {
                image = display->default_cursor->images[0];
                buffer = wl_cursor_image_get_buffer(image);
+               if (!buffer)
+                       return;
                wl_pointer_set_cursor(pointer, serial,
                                      display->cursor_surface,
                                      image->hotspot_x,
@@ -715,8 +717,16 @@ registry_handle_global(void *data, struct wl_registry 
*registry,
                d->shm = wl_registry_bind(registry, name,
                                          &wl_shm_interface, 1);
                d->cursor_theme = wl_cursor_theme_load(NULL, 32, d->shm);
+               if (!d->cursor_theme) {
+                       fprintf(stderr, "unable to load default theme\n");
+                       return;
+               }
                d->default_cursor =
                        wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
+               if (!d->default_cursor) {
+                       fprintf(stderr, "unable to load default left 
pointer\n");
+                       // TODO: abort ?
+               }
        }
 }
 
diff --git a/clients/window.c b/clients/window.c
index 3136a7d..96b1731 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -1280,6 +1280,10 @@ create_cursors(struct display *display)
        weston_config_destroy(config);
 
        display->cursor_theme = wl_cursor_theme_load(theme, size, display->shm);
+       if (!display->cursor_theme) {
+               fprintf(stderr, "could not load theme '%s'\n", theme);
+               return;
+       }
        free(theme);
        display->cursors =
                xmalloc(ARRAY_LENGTH(cursors) * sizeof display->cursors[0]);
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 238946b..7d9e01b 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -968,7 +968,8 @@ input_set_cursor(struct wayland_input *input)
 
        image = input->compositor->cursor->images[0];
        buffer = wl_cursor_image_get_buffer(image);
-
+       if (!buffer)
+               return;
 
        wl_pointer_set_cursor(input->parent.pointer, input->enter_serial,
                              input->parent.cursor.surface,
@@ -1428,6 +1429,10 @@ create_cursor(struct wayland_compositor *c, struct 
weston_config *config)
        weston_config_section_get_int(s, "cursor-size", &size, 32);
 
        c->cursor_theme = wl_cursor_theme_load(theme, size, c->parent.shm);
+       if (!c->cursor_theme) {
+               fprintf(stderr, "could not load cursor theme\n");
+               return;
+       }
 
        free(theme);
 
-- 
1.8.1.2

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to