[Mesa-dev] [PATCH] gbm-dri: Duplicate image after checking its format.

mateuszx.potrola at intel.com mateuszx.potrola at intel.com
Wed Dec 21 09:55:28 UTC 2016


From: Mateusz Polrola <mateuszx.potrola at intel.com>

If image will be duplicated before checking if its format is supported
it may leak memory, as duplicated image for non supported formats is
not being destroyed.

Signed-off-by: Mateusz Polrola <mateuszx.potrola at intel.com>
---
 src/gbm/backends/dri/gbm_dri.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 45cb42a..941d915 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -679,8 +679,6 @@ gbm_dri_bo_import(struct gbm_device *gbm,
          return NULL;
       }
 
-      image = dri->image->dupImage(wb->driver_buffer, NULL);
-
       switch (wb->format) {
       case WL_DRM_FORMAT_XRGB8888:
          gbm_format = GBM_FORMAT_XRGB8888;
@@ -697,6 +695,8 @@ gbm_dri_bo_import(struct gbm_device *gbm,
       default:
          return NULL;
       }
+
+      image = dri->image->dupImage(wb->driver_buffer, NULL);
       break;
    }
 #endif
-- 
2.5.5

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928



More information about the mesa-dev mailing list