header_nlines = 1 + image->ncolors;
header_nlines = 1 + image->ncolors;    if(header_nlines <= image->ncolors || header_nlines >= UINT_MAX / sizeof(char *)) return(XpmNoMemory);
XpmCreateDataFromXpmImage(data_return, image, info)    char ***data_return;    XpmImage *image;    XpmInfo *info;{    /* calculation variables */    int ErrorStatus;    char buf[BUFSIZ];    char **header = NULL, **data, **sptr, **sptr2, *s;    unsigned int header_size, header_nlines;    unsigned int data_size, data_nlines;    unsigned int extensions = 0, ext_size = 0, ext_nlines = 0;    unsigned int offset, l, n;    *data_return = NULL;    extensions = info && (info->valuemask & XpmExtensions)	&& info->nextensions;    /* compute the number of extensions lines and size */    if (extensions)	CountExtensions(info->extensions, info->nextensions,			&ext_size, &ext_nlines);    /*     * alloc a temporary array of char pointer for the header section which     * is the hints line + the color table lines     */    header_nlines = 1 + image->ncolors;    header_size = sizeof(char *) * header_nlines;    if (header_size >= UINT_MAX / sizeof(char *))	return (XpmNoMemory);    header = (char **) XpmCalloc(header_size, sizeof(char *));    if (!header)	return (XpmNoMemory);    /* print the hints line */    s = buf;#ifndef VOID_SPRINTF    s +=#endif    sprintf(s, "%d %d %d %d", image->width, image->height,	    image->ncolors, image->cpp);#ifdef VOID_SPRINTF    s += strlen(s);#endif    if (info && (info->valuemask & XpmHotspot)) {#ifndef VOID_SPRINTF	s +=#endif	sprintf(s, " %d %d", info->x_hotspot, info->y_hotspot);#ifdef VOID_SPRINTF	s += strlen(s);#endif    }    if (extensions) {	strcpy(s, " XPMEXT");	s += 7;    }    l = s - buf + 1;    *header = (char *) XpmMalloc(l);    if (!*header)	RETURN(XpmNoMemory);    header_size += l;    strcpy(*header, buf);    /* print colors */    ErrorStatus = CreateColors(header + 1, &header_size,			       image->colorTable, image->ncolors, image->cpp);    if (ErrorStatus != XpmSuccess)	RETURN(ErrorStatus);    /* now we know the size needed, alloc the data and copy the header lines */    offset = image->width * image->cpp + 1;    data_size = header_size + (image->height + ext_nlines) * sizeof(char *)	+ image->height * offset + ext_size;    data = (char **) XpmMalloc(data_size);    if (!data)	RETURN(XpmNoMemory);    data_nlines = header_nlines + image->height + ext_nlines;    *data = (char *) (data + data_nlines);    n = image->ncolors;    for (l = 0, sptr = data, sptr2 = header; l <= n; l++, sptr++, sptr2++) {	strcpy(*sptr, *sptr2);	*(sptr + 1) = *sptr + strlen(*sptr2) + 1;    }    /* print pixels */    data[header_nlines] = (char *) data + header_size	+ (image->height + ext_nlines) * sizeof(char *);    CreatePixels(data + header_nlines, image->width, image->height,		 image->cpp, image->data, image->colorTable);    /* print extensions */    if (extensions)	CreateExtensions(data + header_nlines + image->height - 1, offset,			 info->extensions, info->nextensions,			 ext_nlines);    *data_return = data;    ErrorStatus = XpmSuccess;/* exit point, free only locally allocated variables */exit:    if (header) {	for (l = 0; l < header_nlines; l++)	    if (header[l])		XpmFree(header[l]);		XpmFree(header);    }    return(ErrorStatus);}