summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-01-26 15:49:24 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-02-16 14:47:49 +0100
commit4c5e2137acd06f258d7324658d94e660bd37a5ac (patch)
tree1e777ee5874343a83e67a3928a680fcfd99f975b
parent6d67f2f318ec44613fe025694b5d6290f692fba1 (diff)
downloadefl-4c5e2137acd06f258d7324658d94e660bd37a5ac.tar.gz
eet: fix error handling when decoding TGV file format.
-rw-r--r--src/lib/eet/eet_image.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/lib/eet/eet_image.c b/src/lib/eet/eet_image.c
index 6cc05e59fd..a01f98c489 100644
--- a/src/lib/eet/eet_image.c
+++ b/src/lib/eet/eet_image.c
@@ -565,6 +565,7 @@ eet_data_image_etc2_decode(const void *data,
Eina_Binbuf *bin;
Emile_Image_Load_Error error;
int i;
+ int r = 0;
// Fix for ABI incompatibility between 1.10 and 1.11
if (cspace == 8) cspace = 9;
@@ -572,18 +573,19 @@ eet_data_image_etc2_decode(const void *data,
bin = eina_binbuf_manage_read_only_new_length(data, length);
if (!bin) return 0;
+ memset(&opts, 0, sizeof (Emile_Image_Load_Opts));
opts.region.x = dst_x;
opts.region.y = dst_y;
opts.region.w = dst_w;
opts.region.h = dst_h;
image = emile_image_tgv_memory_open(bin, &opts, NULL, &error);
- if (!image) return 0;
+ if (!image) goto on_error;
- memset(&prop, sizeof (prop), 0);
+ memset(&prop, 0, sizeof (prop));
- if (!emile_image_head(image, &prop, sizeof (Emile_Image_Load_Opts), &error))
- return 0;
+ if (!emile_image_head(image, &prop, sizeof (Emile_Image_Property), &error))
+ goto on_error;
for (i = 0; prop.cspaces[i] != EMILE_COLORSPACE_ARGB8888; i++)
{
@@ -593,37 +595,43 @@ eet_data_image_etc2_decode(const void *data,
switch (cspace)
{
case EMILE_COLORSPACE_ETC1:
- if (lossy != EET_IMAGE_ETC1) return 0;
- if (alpha != EINA_FALSE) return 0;
+ if (lossy != EET_IMAGE_ETC1) goto on_error;
+ if (alpha != EINA_FALSE) goto on_error;
break;
case EMILE_COLORSPACE_RGB8_ETC2:
- if (lossy != EET_IMAGE_ETC2_RGB) return 0;
- if (alpha != EINA_FALSE) return 0;
+ if (lossy != EET_IMAGE_ETC2_RGB) goto on_error;
+ if (alpha != EINA_FALSE) goto on_error;
break;
case EMILE_COLORSPACE_RGBA8_ETC2_EAC:
- if (lossy != EET_IMAGE_ETC2_RGBA) return 0;
- if (alpha != EINA_TRUE) return 0;
+ if (lossy != EET_IMAGE_ETC2_RGBA) goto on_error;
+ if (alpha != EINA_TRUE) goto on_error;
break;
case EMILE_COLORSPACE_ETC1_ALPHA:
- if (lossy != EET_IMAGE_ETC1_ALPHA) return 0;
- if (alpha != EINA_TRUE) return 0;
+ if (lossy != EET_IMAGE_ETC1_ALPHA) goto on_error;
+ if (alpha != EINA_TRUE) goto on_error;
break;
case EET_COLORSPACE_ARGB8888:
break;
default:
- return 0;
+ goto on_error;
}
prop.cspace = cspace;
if (!emile_image_data(image, &prop, sizeof (Emile_Image_Load_Opts), p, &error))
- return 0;
+ goto on_error;
// TODO: Add support for more unpremultiplied modes (ETC2)
if ((cspace == EET_COLORSPACE_ARGB8888) && !prop.premul)
_eet_argb_premul(p, prop.w * prop.h);
- return 1;
+ r = 1;
+
+ on_error:
+ emile_image_close(image);
+ eina_binbuf_free(bin);
+
+ return r;
}
static void *