summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-03-17 08:50:24 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-03-17 09:58:19 +0100
commitce340ce2fb9f9af459bd57a965b864c3b0afe2c9 (patch)
treea0d87879d1c557a2f87094e4f56687b1d76a1b37 /src/lib
parentc221f33428ff8dfb8e8754573bdda7c72c4ffe71 (diff)
downloadefl-ce340ce2fb9f9af459bd57a965b864c3b0afe2c9.tar.gz
eet: fix error handling when decoding TGV file format.
Diffstat (limited to 'src/lib')
-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 *