diff --git a/src/modules/Image/encodings/ilbm.c b/src/modules/Image/encodings/ilbm.c index 6f173ff48252de5d78837ab5036325b62924da16..8912c966e1230c8b23c7e82f51f845598e9eed82 100644 --- a/src/modules/Image/encodings/ilbm.c +++ b/src/modules/Image/encodings/ilbm.c @@ -1,9 +1,3 @@ -/* -|| This file is part of Pike. For copyright information see COPYRIGHT. -|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING -|| for more information. -*/ - /* **! module Image **! submodule ILBM @@ -215,6 +209,7 @@ static ptrdiff_t unpackByteRun1(unsigned char *src, ptrdiff_t srclen, srclen -= c+2; if(1+c>left) { c = left-1; + left = 0; } else left -= c+1; do { *dest++ = *src++; } while(c--); @@ -262,11 +257,14 @@ static void parse_body(struct BMHD *bmhd, unsigned char *body, ptrdiff_t blen, int rbyt = ((bmhd->w+15)&~15)>>3; int eplanes = (bmhd->masking == mskHasMask? bmhd->nPlanes+1:bmhd->nPlanes); unsigned char *line=0; - unsigned INT32 *cptr, *cline = alloca((rbyt<<3)*sizeof(unsigned INT32)); + unsigned INT32 *cptr, *cline; ptrdiff_t suse=0; rgb_group *dest = img->img; rgb_group *adest = (alpha==NULL? NULL : alpha->img); + check_c_stack((rbyt<<3)*sizeof(unsigned INT32)); + cline = alloca((rbyt<<3)*sizeof(unsigned INT32)); + if(ctable != NULL && ctable->type != NCT_FLAT) ctable = NULL; @@ -274,6 +272,7 @@ static void parse_body(struct BMHD *bmhd, unsigned char *body, ptrdiff_t blen, case cmpNone: break; case cmpByteRun1: + check_c_stack(rbyt*eplanes); line = alloca(rbyt*eplanes); break; default: