Evas: Free variable in error path
authorJean-Philippe Andre <jp.andre@samsung.com>
Fri, 13 Feb 2015 02:06:25 +0000 (11:06 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Fri, 13 Feb 2015 02:07:39 +0000 (11:07 +0900)
Fixes CID 1270032
  Resource leaks  (RESOURCE_LEAK)
  Variable "exim" going out of scope leaks the storage it points to.

src/modules/evas/engines/software_x11/evas_xlib_image.c

index 9514df4..166f22a 100644 (file)
@@ -86,16 +86,17 @@ evas_xlib_image_native_set(void *data, void *image, void *native)
         w = im->cache_entry.w;
         h = im->cache_entry.h;
 
+        n = calloc(1, sizeof(Native));
+        if (!n) return NULL;
+
         exim = ecore_x_image_new(w, h, vis, depth);
         if (!exim)
           {
              ERR("ecore_x_image_new failed.");
+             free(n);
              return NULL;
           }
 
-        n = calloc(1, sizeof(Native));
-        if (!n) return NULL;
-
         memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
         n->pixmap = pm;
         n->visual = vis;