Lines 491-497
Link Here
|
491 |
readcolmap(in,im->cmap,lnumcols); |
491 |
readcolmap(in,im->cmap,lnumcols); |
492 |
} |
492 |
} |
493 |
|
493 |
|
494 |
if((im->image=(byte *)malloc(width*height))==NULL) |
494 |
if(WH_BAD(width,height) || (im->image=(byte *)malloc(width*height))==NULL) |
495 |
{ |
495 |
{ |
496 |
fclose(in); |
496 |
fclose(in); |
497 |
return(_PICERR_NOMEM); |
497 |
return(_PICERR_NOMEM); |
Lines 599-605
Link Here
|
599 |
|
599 |
|
600 |
/* allocate main image and palette */ |
600 |
/* allocate main image and palette */ |
601 |
|
601 |
|
602 |
if((*theimageptr=(byte *)malloc(ginfo->width*ginfo->height))==NULL) |
602 |
if(WH_BAD(ginfo->width,ginfo->height) || |
|
|
603 |
(*theimageptr=(byte *)malloc(ginfo->width*ginfo->height))==NULL) |
603 |
{ |
604 |
{ |
604 |
images_cleanup(); |
605 |
images_cleanup(); |
605 |
return(_PICERR_NOMEM); |
606 |
return(_PICERR_NOMEM); |
Lines 668-674
Link Here
|
668 |
for(i=0;i<imagecount;i++) |
669 |
for(i=0;i<imagecount;i++) |
669 |
{ |
670 |
{ |
670 |
int x,y,left,w; |
671 |
int x,y,left,w; |
671 |
unsigned char *ptr1,*ptr2; |
672 |
unsigned char *ptr1,*ptr2,*oldptr1; |
|
|
673 |
|
674 |
/* basic width/height vs. "screen" checks, left/top handled elsewhere */ |
675 |
if(images[i]->width>swidth) images[i]->width=swidth; |
676 |
if(images[i]->height>sheight) images[i]->height=sheight; |
672 |
|
677 |
|
673 |
/* for images after the first, we need to set the initial contents |
678 |
/* for images after the first, we need to set the initial contents |
674 |
* (as far as GIF is concerned, the `screen' contents) as directed |
679 |
* (as far as GIF is concerned, the `screen' contents) as directed |
Lines 708-727
Link Here
|
708 |
*/ |
713 |
*/ |
709 |
} |
714 |
} |
710 |
} |
715 |
} |
711 |
|
716 |
|
712 |
ptr1=ptr+images[i]->left+images[i]->top*swidth; |
717 |
/* an image with left or top offscreen is broken, but relying |
713 |
ptr2=images[i]->image; |
718 |
* unknowingly on the image not appearing at all. So skip it. |
714 |
|
719 |
*/ |
715 |
for(y=0;y<images[i]->height;y++) |
720 |
if(images[i]->left<swidth && images[i]->top<sheight) |
716 |
{ |
721 |
{ |
717 |
for(x=0;x<images[i]->width;x++) |
722 |
ptr1=ptr+images[i]->left+images[i]->top*swidth; |
718 |
if(!(images[i]->gcb_control&1) || /* if no transparent col defined */ |
|
|
719 |
images[i]->transparent_col!=*ptr2) |
720 |
*ptr1++=*ptr2++; |
721 |
else |
722 |
ptr1++,ptr2++; |
723 |
|
723 |
|
724 |
ptr1+=swidth-images[i]->width; |
724 |
for(y=0;y<images[i]->height && images[i]->top+y<sheight;y++) |
|
|
725 |
{ |
726 |
oldptr1=ptr1; |
727 |
ptr2=images[i]->image+y*images[i]->width; |
728 |
|
729 |
for(x=0;x<images[i]->width && images[i]->left+x<swidth;x++) |
730 |
if(!(images[i]->gcb_control&1) || /* if no transparent col defined */ |
731 |
images[i]->transparent_col!=*ptr2) |
732 |
*ptr1++=*ptr2++; |
733 |
else |
734 |
ptr1++,ptr2++; |
735 |
|
736 |
ptr1=oldptr1+swidth; |
737 |
} |
725 |
} |
738 |
} |
726 |
|
739 |
|
727 |
ptr+=swidth*sheight; |
740 |
ptr+=swidth*sheight; |