emile: fix memory leak.

CID 1288924 & 1288923
This commit is contained in:
Cedric BAIL 2015-04-25 19:27:20 +02:00
parent 5d59a403cd
commit 888057f0bc
1 changed files with 12 additions and 5 deletions

View File

@ -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