cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=888057f0bc4a4af91d91e05f15197cce169fbcfc

commit 888057f0bc4a4af91d91e05f15197cce169fbcfc
Author: Cedric BAIL <ced...@osg.samsung.com>
Date:   Sat Apr 25 19:27:20 2015 +0200

    emile: fix memory leak.
    
    CID 1288924 & 1288923
---
 src/lib/emile/emile_image.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/lib/emile/emile_image.c b/src/lib/emile/emile_image.c
index c5eb1f3..06a5da4 100644
--- a/src/lib/emile/emile_image.c
+++ b/src/lib/emile/emile_image.c
@@ -1599,6 +1599,9 @@ _emile_jpeg_data(Emile_Image *image,
    volatile int degree = 0;
    volatile Eina_Bool change_wh = EINA_FALSE;
    Eina_Bool line_done = EINA_FALSE;
+   Eina_Bool ptrg_free = EINA_FALSE;
+   Eina_Bool ptrag_free = EINA_FALSE;
+   Eina_Bool r = EINA_FALSE;
    unsigned int length;
 
    if (sizeof(Emile_Image_Property) != property_size)
@@ -1781,11 +1784,13 @@ _emile_jpeg_data(Emile_Image *image,
           {
              ptrg = malloc(w * h * sizeof(uint8_t));
              ptrg_rotate = ptrg;
+             ptrg_free = EINA_TRUE;
           }
         else if (prop->cspace == EMILE_COLORSPACE_AGRY88)
           {
              ptrag = malloc(w * h * sizeof(uint16_t));
              ptrag_rotate = ptrag;
+             ptrag_free = EINA_TRUE;
           }
         else
           {
@@ -2216,15 +2221,17 @@ done:
      }
    /* end data decoding */
    jpeg_finish_decompress(&cinfo);
-   jpeg_destroy_decompress(&cinfo);
-   _emile_jpeg_membuf_src_term(&cinfo);
    *error = EMILE_IMAGE_LOAD_ERROR_NONE;
-   return EINA_TRUE;
+   r = EINA_TRUE;
+
+ on_error:
+   if (ptrg_free) free(ptrg);
+   if (ptrag_free) free(ptrag);
 
-on_error:
    jpeg_destroy_decompress(&cinfo);
    _emile_jpeg_membuf_src_term(&cinfo);
-   return EINA_FALSE;
+   return r;
+
 }
 
 static void

-- 


Reply via email to