% July 1992 %
% %
% %
-% Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
% obtain a copy of the License at %
% %
-% http://www.imagemagick.org/script/license.php %
+% https://www.imagemagick.org/script/license.php %
% %
% Unless required by applicable law or agreed to in writing, software %
% distributed under the License is distributed on an "AS IS" BASIS, %
i;
static const char
- *targets[NumberTargets] = { "c ", "g ", "g4 ", "m ", "b ", "s " };
+ *const targets[NumberTargets] = { "c ", "g ", "g4 ", "m ", "b ", "s " };
if (search_start != MagickFalse)
{
{
char
*grey,
- key[MaxTextExtent],
- target[MaxTextExtent],
+ key[MagickPathExtent],
+ target[MagickPathExtent],
*xpm_buffer;
Image
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
/*
Read XPM file.
*/
- length=MaxTextExtent;
+ length=MagickPathExtent;
xpm_buffer=(char *) AcquireQuantumMemory((size_t) length,sizeof(*xpm_buffer));
if (xpm_buffer == (char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if ((*p == '}') && (*(p+1) == ';'))
break;
p+=strlen(p);
- if ((size_t) (p-xpm_buffer+MaxTextExtent) < length)
+ if ((size_t) (p-xpm_buffer+MagickPathExtent) < length)
continue;
length<<=1;
- xpm_buffer=(char *) ResizeQuantumMemory(xpm_buffer,length+MaxTextExtent,
+ xpm_buffer=(char *) ResizeQuantumMemory(xpm_buffer,length+MagickPathExtent,
sizeof(*xpm_buffer));
if (xpm_buffer == (char *) NULL)
break;
if (count == 4)
break;
}
- if ((count != 4) || (width > 10) || (image->columns == 0) ||
- (image->rows == 0) || (image->colors == 0))
- ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+ if ((count != 4) || (width == 0) || (width > 3) ||
+ (image->columns == 0) || (image->rows == 0) ||
+ (image->colors == 0) || (image->colors > MaxColormapSize))
+ {
+ xpm_buffer=DestroyString(xpm_buffer);
+ ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+ }
/*
Remove unquoted characters.
*/
active=MagickFalse;
- q=xpm_buffer;
- while (*p != '\0')
+ for (q=xpm_buffer; *p != '\0'; )
{
if (*p++ == '"')
{
(void *(*)(void *)) NULL);
if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
{
+ xpm_colors=DestroySplayTree(xpm_colors);
xpm_buffer=DestroyString(xpm_buffer);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
{
p=next;
next=NextXPMLine(p);
- (void) CopyXPMColor(key,p,MagickMin((size_t) width,MaxTextExtent-1));
+ (void) CopyXPMColor(key,p,MagickMin((size_t) width,MagickPathExtent-1));
status=AddValueToSplayTree(xpm_colors,ConstantString(key),(void *) j);
/*
Parse color.
*/
- (void) CopyMagickString(target,"gray",MaxTextExtent);
+ (void) CopyMagickString(target,"gray",MagickPathExtent);
q=ParseXPMColor(p+width,MagickTrue);
if (q != (char *) NULL)
{
break;
if (next != (char *) NULL)
(void) CopyXPMColor(target,q,MagickMin((size_t) (next-q),
- MaxTextExtent-1));
+ MagickPathExtent-1));
else
- (void) CopyMagickString(target,q,MaxTextExtent);
+ (void) CopyMagickString(target,q,MagickPathExtent);
q=ParseXPMColor(target,MagickFalse);
if (q != (char *) NULL)
*q='\0';
*/
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
- return(DestroyImageList(image));
+ {
+ xpm_colors=DestroySplayTree(xpm_colors);
+ xpm_buffer=DestroyString(xpm_buffer);
+ return(DestroyImageList(image));
+ }
for (y=0; y < (ssize_t) image->rows; y++)
{
p=NextXPMLine(p);
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- ssize_t count=CopyXPMColor(key,p,MagickMin(width,MaxTextExtent-1));
+ ssize_t count=CopyXPMColor(key,p,MagickMin(width,MagickPathExtent-1));
if (count != (ssize_t) width)
break;
j=(ssize_t) GetValueFromSplayTree(xpm_colors,key);
MagickInfo
*entry;
- entry=SetMagickInfo("PICON");
+ entry=AcquireMagickInfo("XPM","PICON","Personal Icon");
entry->decoder=(DecodeImageHandler *) ReadXPMImage;
entry->encoder=(EncodeImageHandler *) WritePICONImage;
entry->flags^=CoderAdjoinFlag;
- entry->description=ConstantString("Personal Icon");
- entry->module=ConstantString("XPM");
(void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("PM");
+ entry=AcquireMagickInfo("XPM","PM","X Windows system pixmap (color)");
entry->decoder=(DecodeImageHandler *) ReadXPMImage;
entry->encoder=(EncodeImageHandler *) WriteXPMImage;
entry->flags^=CoderAdjoinFlag;
entry->flags|=CoderStealthFlag;
- entry->description=ConstantString("X Windows system pixmap (color)");
- entry->module=ConstantString("XPM");
(void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("XPM");
+ entry=AcquireMagickInfo("XPM","XPM","X Windows system pixmap (color)");
entry->decoder=(DecodeImageHandler *) ReadXPMImage;
entry->encoder=(EncodeImageHandler *) WriteXPMImage;
entry->magick=(IsImageFormatHandler *) IsXPM;
entry->flags^=CoderAdjoinFlag;
- entry->description=ConstantString("X Windows system pixmap (color)");
- entry->module=ConstantString("XPM");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
"lzxcvbnmMNBVCZASDFGHJKLPIUYTREWQ!~^/()_`'][{}|";
char
- buffer[MaxTextExtent],
- basename[MaxTextExtent],
- name[MaxTextExtent],
- symbol[MaxTextExtent];
+ buffer[MagickPathExtent],
+ basename[MagickPathExtent],
+ name[MagickPathExtent],
+ symbol[MagickPathExtent];
Image
*affinity_image,
Open output image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
blob_info=CloneImageInfo(image_info);
(void) AcquireUniqueFilename(blob_info->filename);
if ((image_info->type != TrueColorType) &&
- (IsImageGray(image,exception) != MagickFalse))
+ (SetImageGray(image,exception) != MagickFalse))
affinity_image=BlobToImage(blob_info,Graymap,GraymapExtent,exception);
else
affinity_image=BlobToImage(blob_info,Colormap,ColormapExtent,exception);
(void) RelinquishUniqueFileResource(blob_info->filename);
blob_info=DestroyImageInfo(blob_info);
if ((picon == (Image *) NULL) || (affinity_image == (Image *) NULL))
- return(MagickFalse);
+ {
+ if (affinity_image != (Image *) NULL)
+ affinity_image=DestroyImage(affinity_image);
+ if (picon != (Image *) NULL)
+ picon=DestroyImage(picon);
+ return(MagickFalse);
+ }
quantize_info=AcquireQuantizeInfo(image_info);
status=RemapImage(quantize_info,picon,affinity_image,exception);
quantize_info=DestroyQuantizeInfo(quantize_info);
*/
(void) WriteBlobString(image,"/* XPM */\n");
GetPathComponent(picon->filename,BasePath,basename);
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"static char *%s[] = {\n",basename);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"/* columns rows colors chars-per-pixel */\n");
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"\"%.20g %.20g %.20g %.20g\",\n",(double) picon->columns,(double)
picon->rows,(double) colors,(double) characters_per_pixel);
(void) WriteBlobString(image,buffer);
if (transparent != MagickFalse)
{
if (i == (ssize_t) (colors-1))
- (void) CopyMagickString(name,"grey75",MaxTextExtent);
+ (void) CopyMagickString(name,"grey75",MagickPathExtent);
}
/*
Write XPM color.
symbol[j]=Cixel[k];
}
symbol[j]='\0';
- (void) FormatLocaleString(buffer,MaxTextExtent,"\"%s c %s\",\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"\"%s c %s\",\n",
symbol,name);
(void) WriteBlobString(image,buffer);
}
symbol[j]=Cixel[k];
}
symbol[j]='\0';
- (void) CopyMagickString(buffer,symbol,MaxTextExtent);
+ (void) CopyMagickString(buffer,symbol,MagickPathExtent);
(void) WriteBlobString(image,buffer);
- p+=GetPixelChannels(image);
+ p+=GetPixelChannels(picon);
}
- (void) FormatLocaleString(buffer,MaxTextExtent,"\"%s\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"\"%s\n",
y == (ssize_t) (picon->rows-1) ? "" : ",");
(void) WriteBlobString(image,buffer);
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
"lzxcvbnmMNBVCZASDFGHJKLPIUYTREWQ!~^/()_`'][{}|";
char
- buffer[MaxTextExtent],
- basename[MaxTextExtent],
- name[MaxTextExtent],
- symbol[MaxTextExtent];
+ buffer[MagickPathExtent],
+ basename[MagickPathExtent],
+ name[MagickPathExtent],
+ symbol[MagickPathExtent];
MagickBooleanType
status;
Open output image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
GetPathComponent(image->filename,BasePath,basename);
if (isalnum((int) ((unsigned char) *basename)) == 0)
{
- (void) FormatLocaleString(buffer,MaxTextExtent,"xpm_%s",basename);
- (void) CopyMagickString(basename,buffer,MaxTextExtent);
+ (void) FormatLocaleString(buffer,MagickPathExtent,"xpm_%s",basename);
+ (void) CopyMagickString(basename,buffer,MagickPathExtent);
}
if (isalpha((int) ((unsigned char) basename[0])) == 0)
basename[0]='_';
for (i=1; basename[i] != '\0'; i++)
if (isalnum((int) ((unsigned char) basename[i])) == 0)
basename[i]='_';
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"static char *%s[] = {\n",basename);
(void) WriteBlobString(image,buffer);
(void) WriteBlobString(image,"/* columns rows colors chars-per-pixel */\n");
- (void) FormatLocaleString(buffer,MaxTextExtent,
+ (void) FormatLocaleString(buffer,MagickPathExtent,
"\"%.20g %.20g %.20g %.20g \",\n",(double) image->columns,(double)
image->rows,(double) image->colors,(double) characters_per_pixel);
(void) WriteBlobString(image,buffer);
pixel.alpha=(double) OpaqueAlpha;
(void) QueryColorname(image,&pixel,XPMCompliance,name,exception);
if (i == opacity)
- (void) CopyMagickString(name,"None",MaxTextExtent);
+ (void) CopyMagickString(name,"None",MagickPathExtent);
/*
Write XPM color.
*/
symbol[j]=Cixel[k];
}
symbol[j]='\0';
- (void) FormatLocaleString(buffer,MaxTextExtent,"\"%s c %s\",\n",symbol,
+ (void) FormatLocaleString(buffer,MagickPathExtent,"\"%s c %s\",\n",symbol,
name);
(void) WriteBlobString(image,buffer);
}
symbol[j]=Cixel[k];
}
symbol[j]='\0';
- (void) CopyMagickString(buffer,symbol,MaxTextExtent);
+ (void) CopyMagickString(buffer,symbol,MagickPathExtent);
(void) WriteBlobString(image,buffer);
p+=GetPixelChannels(image);
}
- (void) FormatLocaleString(buffer,MaxTextExtent,"\"%s\n",
+ (void) FormatLocaleString(buffer,MagickPathExtent,"\"%s\n",
(y == (ssize_t) (image->rows-1) ? "" : ","));
(void) WriteBlobString(image,buffer);
if (image->previous == (Image *) NULL)