loader_tga.c: Properly signal if decoding RLE compressed data failed

Otherwise uninitilized memory could be used later on.

I don't have a test file for this commit.
This commit is contained in:
Fabian Keil 2014-12-04 13:59:31 +01:00 committed by Carsten Haitzler (Rasterman)
parent 2fdef015ff
commit 6ef51ec4cd
1 changed files with 15 additions and 4 deletions

View File

@ -413,11 +413,17 @@ load(ImlibImage * im, ImlibProgressFunction progress,
DATA32 *final_pixel = dataptr + im->w * im->h;
/* loop until we've got all the pixels or run out of input */
while ((dataptr < final_pixel) &&
((bufptr + 1 + (bpp / 8)) <= bufend))
while ((dataptr < final_pixel))
{
int count;
if ((bufptr + 1 + (bpp / 8)) > bufend)
{
munmap(seg, ss.st_size);
close(fd);
return 0;
}
curbyte = *bufptr++;
count = (curbyte & 0x7F) + 1;
@ -471,9 +477,14 @@ load(ImlibImage * im, ImlibProgressFunction progress,
{
int i;
for (i = 0; (i < count) && (dataptr < final_pixel) &&
((bufptr + (bpp / 8)) <= bufend); i++)
for (i = 0; (i < count) && (dataptr < final_pixel); i++)
{
if ((bufptr + 1 + (bpp / 8)) > bufend)
{
munmap(seg, ss.st_size);
close(fd);
return 0;
}
switch (bpp)
{