Skip to content

Commit

Permalink
Moved check for #92.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Feb 2, 2016
1 parent 57798f3 commit 57be8f9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions coders/psd.c
Expand Up @@ -399,6 +399,11 @@ static ssize_t DecodePSDPixels(const size_t number_compact_pixels,
const unsigned char *compact_pixels,const ssize_t depth,
const size_t number_pixels,unsigned char *pixels)
{
#define CheckNumberCompactPixels \
if (packets == 0) \
return(i); \
packets--

#define CheckNumberPixels(count) \
if (((ssize_t) i + count) > (ssize_t) number_pixels) \
return(i); \
Expand Down Expand Up @@ -427,7 +432,7 @@ static ssize_t DecodePSDPixels(const size_t number_compact_pixels,
if (length > 128)
{
length=256-length+1;
packets--;
CheckNumberCompactPixels;
pixel=(*compact_pixels++);
for (j=0; j < (ssize_t) length; j++)
{
Expand Down Expand Up @@ -475,6 +480,7 @@ static ssize_t DecodePSDPixels(const size_t number_compact_pixels,
length++;
for (j=0; j < (ssize_t) length; j++)
{
CheckNumberCompactPixels;
switch (depth)
{
case 1:
Expand Down Expand Up @@ -513,9 +519,6 @@ static ssize_t DecodePSDPixels(const size_t number_compact_pixels,
break;
}
}
if (packets == 0)
return(i);
packets--;
compact_pixels++;
}
}
Expand Down

0 comments on commit 57be8f9

Please sign in to comment.