evas_image: fix memory leak

Summary:
On the sw engine, an im could be changed and removed by evas_cache_image_size_set.
In this case, there is no chance to free its resource and ends up in memory leak.

Reviewers: Hermet, raster, jsuya, cedric

Reviewed By: cedric

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10334
This commit is contained in:
Shinwoo Kim 2019-10-14 11:09:31 +09:00 committed by Mike Blumenkrantz
parent e6f1146ece
commit 8815d282ff
1 changed files with 18 additions and 2 deletions

View File

@ -1252,9 +1252,25 @@ eng_image_size_get(void *data EINA_UNUSED, void *image, int *w, int *h)
static void *
eng_image_size_set(void *data EINA_UNUSED, void *image, int w, int h)
{
Image_Entry *im = image;
RGBA_Image *rm;
Image_Entry *im = image, *im2;
if (!im) return NULL;
return evas_cache_image_size_set(im, w, h);
/* sw engine im could be changed and removed in evas_cache_image_size_set.
in this case, there is no chance to free its resource. */
evas_cache_image_ref(im);
im2 = evas_cache_image_size_set(im, w, h);
if (im != im2 && im->references == 1)
{
rm = (RGBA_Image *)im;
if (rm->native.data)
{
if (rm->native.func.free)
rm->native.func.free(im);
}
}
evas_cache_image_drop(im);
return im2;
}
static void *