evas sw generic - handle alloc failures correctly for map struct

map struct allocation was not handled right - we assumed successthen
later checked for failure with an if() after using the ptr. this
should fix CID 1353722
This commit is contained in:
Carsten Haitzler 2016-07-09 12:28:05 +09:00
parent de9277460a
commit cdbd437c5f
1 changed files with 18 additions and 12 deletions

View File

@ -1577,6 +1577,11 @@ eng_image_data_map(void *engdata EINA_UNUSED, void **image,
}
map = calloc(1, sizeof(*map));
if (!map)
{
free(data);
return NULL;
}
map->allocated = EINA_TRUE;
map->cspace = cspace;
map->rx = rx;
@ -1597,6 +1602,8 @@ eng_image_data_map(void *engdata EINA_UNUSED, void **image,
// no copy
int end_offset = _evas_common_rgba_image_data_offset(x + w, y + h, 0, 0, 0, im) - src_stride;
map = calloc(1, sizeof(*map));
if (!map) return NULL;
map->baseptr = im->image.data8;
map->ptr = im->image.data8 + src_offset;
map->size = end_offset - src_offset;
@ -1607,10 +1614,14 @@ eng_image_data_map(void *engdata EINA_UNUSED, void **image,
int size = _evas_common_rgba_image_data_offset(w, h, 0, 0, 0, im);
data = malloc(size);
if (!data) return NULL;
map = calloc(1, sizeof(*map));
if (!map)
{
free(data);
return NULL;
}
memcpy(data, im->image.data8 + src_offset, size);
map = calloc(1, sizeof(*map));
map->allocated = EINA_TRUE;
map->baseptr = data;
map->ptr = data;
@ -1624,16 +1635,11 @@ eng_image_data_map(void *engdata EINA_UNUSED, void **image,
map->stride = src_stride;
}
if (map)
{
im->maps = (RGBA_Image_Data_Map *)
eina_inlist_prepend(EINA_INLIST_GET(im->maps), EINA_INLIST_GET(map));
if (length) *length = map->size;
if (stride) *stride = map->stride;
return map->ptr;
}
return NULL;
im->maps = (RGBA_Image_Data_Map *)
eina_inlist_prepend(EINA_INLIST_GET(im->maps), EINA_INLIST_GET(map));
if (length) *length = map->size;
if (stride) *stride = map->stride;
return map->ptr;
}
static void