From 5f301fe2e681e72988f00d610a617a1c90c80b51 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Fri, 27 Jan 2017 17:29:05 +0000 Subject: [PATCH] gbm/dri: fix memory leaks in error path Signed-off-by: Eric Engestrom [Emil Velikov: make sure it builds] Signed-off-by: Emil Velikov --- src/gbm/backends/dri/gbm_dri.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 45cb42a8625..ac7ede87b64 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -695,6 +695,7 @@ gbm_dri_bo_import(struct gbm_device *gbm, gbm_format = GBM_FORMAT_YUYV; break; default: + dri->image->destroyImage(image); return NULL; } break; @@ -715,6 +716,7 @@ gbm_dri_bo_import(struct gbm_device *gbm, gbm_format = gbm_dri_to_gbm_format(dri_format); if (gbm_format == 0) { errno = EINVAL; + dri->image->destroyImage(image); return NULL; } break; @@ -759,8 +761,10 @@ gbm_dri_bo_import(struct gbm_device *gbm, bo = calloc(1, sizeof *bo); - if (bo == NULL) + if (bo == NULL) { + dri->image->destroyImage(image); return NULL; + } bo->image = image; @@ -771,6 +775,7 @@ gbm_dri_bo_import(struct gbm_device *gbm, if (dri->image->base.version >= 2 && !dri->image->validateUsage(bo->image, dri_use)) { errno = EINVAL; + dri->image->destroyImage(bo->image); free(bo); return NULL; } -- 2.30.2