egl/dri2: Check return value of __DRI2fence::create_fence()
authorChad Versace <chad.versace@intel.com>
Wed, 6 May 2015 02:05:20 +0000 (19:05 -0700)
committerChad Versace <chad.versace@intel.com>
Wed, 6 May 2015 14:55:41 +0000 (07:55 -0700)
If it returns NULL, then return early with an error.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/egl/drivers/dri2/egl_dri2.c

index 1e843ed8fd913e02b72cfed4b515145db21610d2..8ed1dda38a634a209066e43b82037f1e41e74fbd 100644 (file)
@@ -2232,6 +2232,13 @@ dri2_create_sync(_EGLDriver *drv, _EGLDisplay *dpy,
    switch (type) {
    case EGL_SYNC_FENCE_KHR:
       dri2_sync->fence = dri2_dpy->fence->create_fence(dri2_ctx->dri_context);
+      if (!dri2_sync->fence) {
+         /* Why did it fail? DRI doesn't return an error code, so we emit
+          * a generic EGL error that doesn't communicate user error. */
+         _eglError(EGL_BAD_ALLOC, "eglCreateSyncKHR");
+         free(dri2_sync);
+         return NULL;
+      }
       break;
 
    case EGL_SYNC_CL_EVENT_KHR: