summaryrefslogtreecommitdiff
path: root/src/lib/eet
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/eet
parentc221f33428ff8dfb8e8754573bdda7c72c4ffe71 (diff)
eet: fix error handling when decoding TGV file format.
Diffstat (limited to 'src/lib/eet')
-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,
565 Eina_Binbuf *bin; 565 Eina_Binbuf *bin;
566 Emile_Image_Load_Error error; 566 Emile_Image_Load_Error error;
567 int i; 567 int i;
568 int r = 0;
568 569
569 // Fix for ABI incompatibility between 1.10 and 1.11 570 // Fix for ABI incompatibility between 1.10 and 1.11
570 if (cspace == 8) cspace = 9; 571 if (cspace == 8) cspace = 9;
@@ -572,18 +573,19 @@ eet_data_image_etc2_decode(const void *data,
572 bin = eina_binbuf_manage_read_only_new_length(data, length); 573 bin = eina_binbuf_manage_read_only_new_length(data, length);
573 if (!bin) return 0; 574 if (!bin) return 0;
574 575
576 memset(&opts, 0, sizeof (Emile_Image_Load_Opts));
575 opts.region.x = dst_x; 577 opts.region.x = dst_x;
576 opts.region.y = dst_y; 578 opts.region.y = dst_y;
577 opts.region.w = dst_w; 579 opts.region.w = dst_w;
578 opts.region.h = dst_h; 580 opts.region.h = dst_h;
579 581
580 image = emile_image_tgv_memory_open(bin, &opts, NULL, &error); 582 image = emile_image_tgv_memory_open(bin, &opts, NULL, &error);
581 if (!image) return 0; 583 if (!image) goto on_error;
582 584
583 memset(&prop, sizeof (prop), 0); 585 memset(&prop, 0, sizeof (prop));
584 586
585 if (!emile_image_head(image, &prop, sizeof (Emile_Image_Load_Opts), &error)) 587 if (!emile_image_head(image, &prop, sizeof (Emile_Image_Property), &error))
586 return 0; 588 goto on_error;
587 589
588 for (i = 0; prop.cspaces[i] != EMILE_COLORSPACE_ARGB8888; i++) 590 for (i = 0; prop.cspaces[i] != EMILE_COLORSPACE_ARGB8888; i++)
589 { 591 {
@@ -593,37 +595,43 @@ eet_data_image_etc2_decode(const void *data,
593 switch (cspace) 595 switch (cspace)
594 { 596 {
595 case EMILE_COLORSPACE_ETC1: 597 case EMILE_COLORSPACE_ETC1:
596 if (lossy != EET_IMAGE_ETC1) return 0; 598 if (lossy != EET_IMAGE_ETC1) goto on_error;
597 if (alpha != EINA_FALSE) return 0; 599 if (alpha != EINA_FALSE) goto on_error;
598 break; 600 break;
599 case EMILE_COLORSPACE_RGB8_ETC2: 601 case EMILE_COLORSPACE_RGB8_ETC2:
600 if (lossy != EET_IMAGE_ETC2_RGB) return 0; 602 if (lossy != EET_IMAGE_ETC2_RGB) goto on_error;
601 if (alpha != EINA_FALSE) return 0; 603 if (alpha != EINA_FALSE) goto on_error;
602 break; 604 break;
603 case EMILE_COLORSPACE_RGBA8_ETC2_EAC: 605 case EMILE_COLORSPACE_RGBA8_ETC2_EAC:
604 if (lossy != EET_IMAGE_ETC2_RGBA) return 0; 606 if (lossy != EET_IMAGE_ETC2_RGBA) goto on_error;
605 if (alpha != EINA_TRUE) return 0; 607 if (alpha != EINA_TRUE) goto on_error;
606 break; 608 break;
607 case EMILE_COLORSPACE_ETC1_ALPHA: 609 case EMILE_COLORSPACE_ETC1_ALPHA:
608 if (lossy != EET_IMAGE_ETC1_ALPHA) return 0; 610 if (lossy != EET_IMAGE_ETC1_ALPHA) goto on_error;
609 if (alpha != EINA_TRUE) return 0; 611 if (alpha != EINA_TRUE) goto on_error;
610 break; 612 break;
611 case EET_COLORSPACE_ARGB8888: 613 case EET_COLORSPACE_ARGB8888:
612 break; 614 break;
613 default: 615 default:
614 return 0; 616 goto on_error;
615 } 617 }
616 618
617 prop.cspace = cspace; 619 prop.cspace = cspace;
618 620
619 if (!emile_image_data(image, &prop, sizeof (Emile_Image_Load_Opts), p, &error)) 621 if (!emile_image_data(image, &prop, sizeof (Emile_Image_Load_Opts), p, &error))
620 return 0; 622 goto on_error;
621 623
622 // TODO: Add support for more unpremultiplied modes (ETC2) 624 // TODO: Add support for more unpremultiplied modes (ETC2)
623 if ((cspace == EET_COLORSPACE_ARGB8888) && !prop.premul) 625 if ((cspace == EET_COLORSPACE_ARGB8888) && !prop.premul)
624 _eet_argb_premul(p, prop.w * prop.h); 626 _eet_argb_premul(p, prop.w * prop.h);
625 627
626 return 1; 628 r = 1;
629
630 on_error:
631 emile_image_close(image);
632 eina_binbuf_free(bin);
633
634 return r;
627} 635}
628 636
629static void * 637static void *