diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 690728d2f70..647303e4ded 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -116,10 +116,17 @@ _eglNativePlatformDetectNativeDisplay(void *nativeDisplay) (void) first_pointer; /* silence unused var warning */ #ifdef HAVE_WAYLAND_PLATFORM - /* wl_display is a wl_proxy, which is a wl_object. - * wl_object's first element points to the interfacetype. */ - if (first_pointer == &wl_display_interface) - return _EGL_PLATFORM_WAYLAND; + if (_eglPointerIsDereferencable(first_pointer)) { + struct wl_interface *interface = first_pointer; + void *child_pointer = *(void **) interface; + + /* wl_display is a wl_proxy, which begins with wl_object. wl_object's + * first element points to the interface; the first element of the + * interface is a string of the interface name. */ + if (_eglPointerIsDereferencable(child_pointer) && + strcmp(interface->name, "wl_display") == 0) + return _EGL_PLATFORM_WAYLAND; + } #endif #ifdef HAVE_DRM_PLATFORM