if (pmap.size >= SIZE_MAX / sizeof(Pixel))
if (pmap.size >= UINT_MAX / sizeof(Pixel))
XpmCreateXpmImageFromImage(display, image, shapeimage,			   xpmimage, attributes)    Display *display;    XImage *image;    XImage *shapeimage;    XpmImage *xpmimage;    XpmAttributes *attributes;{    /* variables stored in the XpmAttributes structure */    unsigned int cpp;    /* variables to return */    PixelsMap pmap;    XpmColor *colorTable = NULL;    int ErrorStatus = 0;    /* calculation variables */    unsigned int width = 0;    unsigned int height = 0;    unsigned int cppm;			/* minimum chars per pixel */    unsigned int c;    /* initialize pmap */    pmap.pixels = NULL;    pmap.pixelindex = NULL;    pmap.size = 256;			/* should be enough most of the time */    pmap.ncolors = 0;    pmap.mask_pixel = 0;    /*     * get geometry     */    if (image) {	width = image->width;	height = image->height;    } else if (shapeimage) {	width = shapeimage->width;	height = shapeimage->height;    }    /*     * retrieve information from the XpmAttributes     */    if (attributes && (attributes->valuemask & XpmCharsPerPixel/* 3.2 backward compatibility code */		       || attributes->valuemask & XpmInfos))/* end 3.2 bc */	cpp = attributes->cpp;    else	cpp = 0;    if ((height > 0 && width >= SIZE_MAX / height) ||	width * height >= SIZE_MAX / sizeof(unsigned int))	RETURN(XpmNoMemory);    pmap.pixelindex =	(unsigned int *) XpmCalloc(width * height, sizeof(unsigned int));    if (!pmap.pixelindex)	RETURN(XpmNoMemory);    if (pmap.size >= SIZE_MAX / sizeof(Pixel)) 	RETURN(XpmNoMemory);    pmap.pixels = (Pixel *) XpmMalloc(sizeof(Pixel) * pmap.size);    if (!pmap.pixels)	RETURN(XpmNoMemory);    /*     * scan shape mask if any     */    if (shapeimage) {#ifndef FOR_MSW# ifndef AMIGA	ErrorStatus = GetImagePixels1(shapeimage, width, height, &pmap,				      storeMaskPixel);# else	ErrorStatus = AGetImagePixels(shapeimage, width, height, &pmap,				      storeMaskPixel);# endif#else	ErrorStatus = MSWGetImagePixels(display, shapeimage, width, height,					&pmap, storeMaskPixel);#endif	if (ErrorStatus != XpmSuccess)	    RETURN(ErrorStatus);    }    /*     * scan the image data     *      * In case depth is 1 or bits_per_pixel is 4, 6, 8, 24 or 32 use optimized     * functions, otherwise use slower but sure general one.     *      */    if (image) {#ifndef FOR_MSW# ifndef AMIGA	if (((image->bits_per_pixel | image->depth) == 1)  &&	    (image->byte_order == image->bitmap_bit_order))	    ErrorStatus = GetImagePixels1(image, width, height, &pmap,					  storePixel);	else if (image->format == ZPixmap) {	    if (image->bits_per_pixel == 8)		ErrorStatus = GetImagePixels8(image, width, height, &pmap);	    else if (image->bits_per_pixel == 16)		ErrorStatus = GetImagePixels16(image, width, height, &pmap);	    else if (image->bits_per_pixel == 32)		ErrorStatus = GetImagePixels32(image, width, height, &pmap);	} else	    ErrorStatus = GetImagePixels(image, width, height, &pmap);# else	ErrorStatus = AGetImagePixels(image, width, height, &pmap,				      storePixel);# endif#else	ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap,					storePixel);#endif	if (ErrorStatus != XpmSuccess)	    RETURN(ErrorStatus);    }    /*     * get rgb values and a string of char, and possibly a name for each     * color     */    if (pmap.ncolors >= SIZE_MAX / sizeof(XpmColor))	RETURN(XpmNoMemory);    colorTable = (XpmColor *) XpmCalloc(pmap.ncolors, sizeof(XpmColor));    if (!colorTable)	RETURN(XpmNoMemory);    /* compute the minimal cpp */    for (cppm = 1, c = MAXPRINTABLE; pmap.ncolors > c; cppm++)	c *= MAXPRINTABLE;    if (cpp < cppm)	cpp = cppm;    if (pmap.mask_pixel) {	ErrorStatus = ScanTransparentColor(colorTable, cpp, attributes);	if (ErrorStatus != XpmSuccess)	    RETURN(ErrorStatus);    }    ErrorStatus = ScanOtherColors(display, colorTable, pmap.ncolors,				  pmap.pixels, pmap.mask_pixel, cpp,				  attributes);    if (ErrorStatus != XpmSuccess)	RETURN(ErrorStatus);    /*     * store found informations in the XpmImage structure     */    xpmimage->width = width;    xpmimage->height = height;    xpmimage->cpp = cpp;    xpmimage->ncolors = pmap.ncolors;    xpmimage->colorTable = colorTable;    xpmimage->data = pmap.pixelindex;    XpmFree(pmap.pixels);    return (XpmSuccess);/* exit point in case of error, free only locally allocated variables */error:    if (pmap.pixelindex)	XpmFree(pmap.pixelindex);    if (pmap.pixels)	XpmFree(pmap.pixels);    if (colorTable)	xpmFreeColorTable(colorTable, pmap.ncolors);    return (ErrorStatus);}