[PATCH 2/2] window: Make a roundtrip to ensure globals have been enumerated.

Paul Liétar paul at lietar.net
Tue May 13 13:54:36 PDT 2014


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 <paul at 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



More information about the wayland-devel mailing list