evas: fix to load BMP file compressed with RLE.
authorjiin.moon <jiin.moon@samsung.com>
Mon, 26 Jan 2015 10:02:58 +0000 (11:02 +0100)
committerCedric BAIL <cedric@osg.samsung.com>
Mon, 26 Jan 2015 10:21:37 +0000 (11:21 +0100)
Summary:
If the file size of RLE compressed image is bigger than original image,
BMP loader doesn't work as well.
@fix

Reviewers: Hermet, cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D1892

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/modules/evas/image_loaders/bmp/evas_image_load_bmp.c

index d54cfdc..cf8156d 100644 (file)
@@ -563,7 +563,11 @@ evas_image_load_file_data_bmp(void *loader_data,
         position = header.offset;
 
         if ((scale_ratio == 1) || (header.comp !=0))
-          buffer = malloc(image_size + 8); // add 8 for padding to avoid checks
+          {
+             if (image_size < fsize - position)
+               image_size = fsize - position;
+             buffer = malloc(image_size + 8); // add 8 for padding to avoid checks
+          }
         else
           {
              scale_surface = malloc(image_w * sizeof(DATA32)); //for one line decoding