From 6098ef824467f685fb34914eb3fef73b3ba18c6f Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 18 Jun 2015 20:16:46 +0100 Subject: [PATCH] egl/drm: plug memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Marek Olšák --- src/egl/drivers/dri2/platform_drm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index a62da4121fe..0d1f4c6e0a7 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -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; -- 2.30.2