egl/drm: plug memory leak
authorEmil Velikov <emil.l.velikov@gmail.com>
Thu, 18 Jun 2015 19:16:46 +0000 (20:16 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Tue, 30 Jun 2015 16:34:11 +0000 (17:34 +0100)
Free the memory for dri2_surf in the unlikely case that one provides
NULL for native_window. Also set the relevant EGL_ERROR to provide
feedback to the user.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/egl/drivers/dri2/platform_drm.c

index a62da4121fed304860d10b32cd2e330c4f436aac..0d1f4c6e0a7f53a6d734025af7289b192ac6e80e 100644 (file)
@@ -115,8 +115,11 @@ dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
 
    switch (type) {
    case EGL_WINDOW_BIT:
-      if (!window)
-         return NULL;
+      if (!window) {
+         _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_create_surface");
+         goto cleanup_surf;
+      }
+
       surf = gbm_dri_surface(window);
       dri2_surf->gbm_surf = surf;
       dri2_surf->base.Width =  surf->base.width;