evas-software-x11: Fix resource leak
authorChris Michael <cp.michael@samsung.com>
Tue, 17 Nov 2015 15:00:19 +0000 (10:00 -0500)
committerChris Michael <cp.michael@samsung.com>
Tue, 17 Nov 2015 15:02:03 +0000 (10:02 -0500)
If we end up leaving evas_xlib_image_dri_native_set due to a failure
to allocate memory, we should free the previously allocated
Evas_DRI_Image so that we don't leak

NB: Fixes Coverity CID1339782

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/modules/evas/engines/software_x11/evas_xlib_dri_image.c

index 2c1c72c..0c0a0ab 100644 (file)
@@ -588,7 +588,10 @@ evas_xlib_image_dri_native_set(void *data, void *image, void *native)
 
    n = calloc(1, sizeof(DRI_Native));
    if (!n)
-     return NULL;
+     {
+        evas_xlib_image_dri_free(exim);
+        return NULL;
+     }
 
    memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
    n->pixmap = pm;