If the compositor enumerates the globals too slowly, the d->sum pointer
is still NULL by the time create_cursors is called, and leads to a null
pointer dereferencing.

A roundtrip is needed to make sure all globals have been enumerated.

Signed-off-by: Paul Liétar <p...@lietar.net>
---
 clients/window.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/clients/window.c b/clients/window.c
index 7b77f93..f52d2bc 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -5320,10 +5320,14 @@ display_create(int *argc, char *argv[])
        d->registry = wl_display_get_registry(d->display);
        wl_registry_add_listener(d->registry, &registry_listener, d);
 
-       if (wl_display_dispatch(d->display) < 0) {
+       if (wl_display_roundtrip(d->display) < 0) {
                fprintf(stderr, "Failed to process Wayland connection: %m\n");
                return NULL;
        }
+       if (d->shm == NULL) {
+               fprintf(stderr, "No wl_shm global\n");
+               return NULL;
+       }
 
 #ifdef HAVE_CAIRO_EGL
        if (init_egl(d) < 0)
-- 
1.9.3

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

Reply via email to