diff options
author | Emil Velikov <[email protected]> | 2017-08-08 15:55:36 +0100 |
---|---|---|
committer | Andres Gomez <[email protected]> | 2017-08-19 17:39:35 +0300 |
commit | 774e77ab64de05d437939110dd11c35a300d47f6 (patch) | |
tree | 18e83255e2ccb965f6a8ee5bb7db3b1e0c8ea194 /src | |
parent | c968de1989026388f690cf41913f47f45c7abbe8 (diff) |
egl: avoid eglCreatePlatform*Surface{EXT,} crash with invalid dpy
If we have an invalid display fed into the functions, the display lookup
will return NULL. Thus as we attempt to get the platform type, we'll
deref. it leading to a crash.
Keep in mind that this will not happen if Mesa is built without X11 or
when the legacy eglCreate*Surface codepaths are used.
A similar check was added with earlier commit 5e97b8f5ce9 ("egl: Fix
crashes in eglCreate*Surface), although it was only applicable when the
surfaceless platform is built.
Cc: [email protected]
Signed-off-by: Emil Velikov <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
(cherry picked from commit 26fbb9eacddb1b809739cb12477bde13501d6d5a)
[Andres Gomez: resolve trivial conflicts]
Signed-off-by: Andres Gomez <[email protected]>
Conflicts:
src/egl/main/eglapi.c
Diffstat (limited to 'src')
-rw-r--r-- | src/egl/main/eglapi.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 08faa78daf2..d54ca2b6746 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -920,7 +920,7 @@ static void * _fixupNativeWindow(_EGLDisplay *disp, void *native_window) { #ifdef HAVE_X11_PLATFORM - if (disp->Platform == _EGL_PLATFORM_X11 && native_window != NULL) { + if (disp && disp->Platform == _EGL_PLATFORM_X11 && native_window != NULL) { /* The `native_window` parameter for the X11 platform differs between * eglCreateWindowSurface() and eglCreatePlatformPixmapSurfaceEXT(). In * eglCreateWindowSurface(), the type of `native_window` is an Xlib @@ -982,7 +982,7 @@ _fixupNativePixmap(_EGLDisplay *disp, void *native_pixmap) * `Pixmap*`. Convert `Pixmap*` to `Pixmap` because that's what * dri2_x11_create_pixmap_surface() expects. */ - if (disp->Platform == _EGL_PLATFORM_X11 && native_pixmap != NULL) + if (disp && disp->Platform == _EGL_PLATFORM_X11 && native_pixmap != NULL) return (void *)(* (Pixmap*) native_pixmap); #endif return native_pixmap; |