egl: don't NULL deref the .get_capabilities function pointer
authorEmil Velikov <emil.velikov@collabora.com>
Mon, 7 Aug 2017 16:23:19 +0000 (17:23 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Sat, 26 Aug 2017 10:22:17 +0000 (11:22 +0100)
One could easily introduce version 3 of the DRI2fenceExtension,
extending the struct, while not implementing the above function.

Thus we'll end up with NULL pointer, and dereferencing it won't fare
too well.

Fixes: 0201f01dc4e ("egl: add EGL_ANDROID_native_fence_sync")
Cc: Rob Clark <robclark@freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/egl/drivers/dri2/egl_dri2.c

index aa6f02a34b5a744b637932c5d53f38cad5c6fc62..83545bab2276abb722807b59b74c78a97bfab76c 100644 (file)
@@ -677,7 +677,8 @@ dri2_setup_screen(_EGLDisplay *disp)
       disp->Extensions.KHR_wait_sync = EGL_TRUE;
       if (dri2_dpy->fence->get_fence_from_cl_event)
          disp->Extensions.KHR_cl_event2 = EGL_TRUE;
-      if (dri2_dpy->fence->base.version >= 2) {
+      if (dri2_dpy->fence->base.version >= 2 &&
+          dri2_dpy->fence->get_capabilities) {
          unsigned capabilities =
             dri2_dpy->fence->get_capabilities(dri2_dpy->dri_screen);
          disp->Extensions.ANDROID_native_fence_sync =