egl: Don't try to dereference native displays unless there's a detectable platform

Not all native displays are pointers to dereferenceable memory, e.g.
DCs on Windows. Don't bother dereferencing if no platforms are available
that can be detected that way.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed By: Bill Kristiansen <billkris@microsoft.com>

Acked-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12727>
This commit is contained in:
Jesse Natalie 2021-09-08 12:51:53 -07:00 committed by Marge Bot
parent eb7d150743
commit 58389dd55f

View file

@ -128,11 +128,10 @@ _eglNativePlatformDetectNativeDisplay(void *nativeDisplay)
if (nativeDisplay == EGL_DEFAULT_DISPLAY)
return _EGL_INVALID_PLATFORM;
#if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM)
if (_eglPointerIsDereferencable(nativeDisplay)) {
void *first_pointer = *(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. */
@ -146,6 +145,7 @@ _eglNativePlatformDetectNativeDisplay(void *nativeDisplay)
return _EGL_PLATFORM_DRM;
#endif
}
#endif
return _EGL_INVALID_PLATFORM;
}