int i, cmaplen;
cmaplen = (biClrUsed) ? biClrUsed : 1 << biBitCount;
/* sanity check user supplied value */
if (cmaplen > 256)
{ bmpError(bname,"invalid colormap length"); goto ERROR; }
for (i=0; i<cmaplen; i++) {
pinfo->b[i] = getc(fp);
pinfo->g[i] = getc(fp);
byte *rledat;
u_long *starttab, *lengthtab;
/* check they are postive */
if ((xsize <= 0) || (ysize <= 0) || (zsize <= 0))
FatalError("invalid image size supplied to LoadIRIS()");
rlebuflen = 2 * xsize + 10;
tablen = ysize * zsize;
/* did they overflow */
if ((rlebuflen <= 0) || (tablen <= 0))
starttab = (u_long *) malloc((size_t) tablen * sizeof(long));
lengthtab = (u_long *) malloc((size_t) tablen * sizeof(long));
rledat = (byte *) malloc((size_t) rlebuflen);
* LoadPCX(fname, pinfo) - loads a PCX file
*/
#include <limits.h>
#include "copyright.h"
/*
byte *image;
/* note: overallocation to make life easier... */
if ((pinfo->h <= 0) || (pinfo->h > INT_MAX-1) ||
(pinfo->w <= 0) || (pinfo->w > INT_MAX-16))
FatalError("bad image specs in pcxLoadImage8()");
image = (byte *) malloc((size_t) (pinfo->h + 1) * pinfo->w + 16);
if (!image) FatalError("Can't alloc 'image' in pcxLoadImage8()");
* WritePM(fp, pic, ptype, w, h, r,g,b, numcols, style, comment)
#include "xv.h"
/* alloc and read in comment, if any */
if (thePic.pm_cmtsize>0) {
if (thePic.pm_cmtsize>0 && thePic.pm_cmtsize<(INT_MAX-1)) {
thePic.pm_cmt = (char *) malloc((size_t) thePic.pm_cmtsize+1);
if (thePic.pm_cmt) {
thePic.pm_cmt[thePic.pm_cmtsize] = '\0'; /* to be safe */