gbm/dri: Fixed buffer object memory leak in case of failure.
authorSiavash Eliasi <siavashserver@gmail.com>
Mon, 10 Feb 2014 09:58:15 +0000 (13:28 +0330)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 28 Feb 2014 23:57:15 +0000 (15:57 -0800)
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
src/gbm/backends/dri/gbm_dri.c

index 5b9998ff6e0ae53512ac127a890e232035efea9b..acf6b246af0b0b3c0d27ddade514dec2144a5ffb 100644 (file)
@@ -611,7 +611,7 @@ gbm_dri_bo_create(struct gbm_device *gbm,
       dri_format = __DRI_IMAGE_FORMAT_XRGB2101010;
       break;
    default:
-      return NULL;
+      goto failed;
    }
 
    if (usage & GBM_BO_USE_SCANOUT)
@@ -628,7 +628,7 @@ gbm_dri_bo_create(struct gbm_device *gbm,
                               dri_format, dri_use,
                               bo);
    if (bo->image == NULL)
-      return NULL;
+      goto failed;
 
    dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HANDLE,
                           &bo->base.base.handle.s32);
@@ -636,6 +636,10 @@ gbm_dri_bo_create(struct gbm_device *gbm,
                           (int *) &bo->base.base.stride);
 
    return &bo->base.base;
+
+failed:
+   free(bo);
+   return NULL;
 }
 
 static struct gbm_surface *