egl: avoid eglCreatePlatform*Surface{EXT,} crash with invalid dpy
authorEmil Velikov <emil.velikov@collabora.com>
Tue, 8 Aug 2017 14:55:36 +0000 (15:55 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 10 Aug 2017 18:41:51 +0000 (19:41 +0100)
commit26fbb9eacddb1b809739cb12477bde13501d6d5a
tree3db8cd91d637ba2a75bdc60a7f237d8aa7fc8dc2
parenta51be4f9a6561b5a97513ddc50f235c8126d3cf2
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: mesa-stable@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/egl/main/eglapi.c