{
#define BitSet(byte,bit) (((byte) & (bit)) == (bit))
#define LSBFirstOrder(x,y) (((y) << 8) | (x))
+#define ThrowGIFException(exception,message) \
+{ \
+ if (profiles != (LinkedListInfo *) NULL) \
+ profiles=DestroyLinkedList(profiles,DestroyGIFProfile); \
+ if (global_colormap != (unsigned char *) NULL) \
+ global_colormap=(unsigned char *) RelinquishMagickMemory(global_colormap); \
+ if (meta_image != (Image *) NULL) \
+ meta_image=DestroyImage(meta_image); \
+ ThrowReaderException((exception),(message)); \
+}
Image
*image,
MagickBooleanType
status;
- MagickSizeType
- max_image_count;
-
register ssize_t
i;
duration=0;
opacity=(-1);
image_count=0;
- max_image_count=GetMagickResourceLimit(ListLengthResource);
for ( ; ; )
{
count=ReadBlob(image,1,&c);
*/
count=ReadBlob(image,1,&c);
if (count != 1)
- {
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,DestroyGIFProfile);
- global_colormap=(unsigned char *) RelinquishMagickMemory(
- global_colormap);
- meta_image=DestroyImage(meta_image);
- ThrowReaderException(CorruptImageError,
- "UnableToReadExtensionBlock");
- }
+ ThrowGIFException(CorruptImageError,"UnableToReadExtensionBlock");
switch (c)
{
case 0xf9:
info=(unsigned char *) AcquireQuantumMemory(255UL,
sizeof(*info));
if (info == (unsigned char *) NULL)
- {
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,DestroyGIFProfile);
- meta_image=DestroyImage(meta_image);
- global_colormap=(unsigned char *) RelinquishMagickMemory(
- global_colormap);
- ThrowReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
- }
+ ThrowGIFException(ResourceLimitError,
+ "MemoryAllocationFailed");
(void) ResetMagickMemory(info,0,255UL*sizeof(*info));
reserved_length=255;
for (info_length=0; ; )
reserved_length,sizeof(*info));
if (info == (unsigned char *) NULL)
{
- meta_image=DestroyImage(meta_image);
- global_colormap=(unsigned char *)
- RelinquishMagickMemory(global_colormap);
+ info=(unsigned char *) RelinquishMagickMemory(info);
ThrowReaderException(ResourceLimitError,
"MemoryAllocationFailed");
}
profile=BlobToStringInfo(info,(size_t) info_length);
if (profile == (StringInfo *) NULL)
{
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,DestroyGIFProfile);
- meta_image=DestroyImage(meta_image);
- global_colormap=(unsigned char *) RelinquishMagickMemory(
- global_colormap);
info=(unsigned char *) RelinquishMagickMemory(info);
ThrowReaderException(ResourceLimitError,
"MemoryAllocationFailed");
image_count++;
if (image_count != 1)
{
- if ((MagickSizeType) image_count == max_image_count)
- {
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,DestroyGIFProfile);
- image=DestroyImageList(image);
- global_colormap=(unsigned char *) RelinquishMagickMemory(
- global_colormap);
- ThrowReaderException(CorruptImageError,"ListLengthExceedsLimit");
- }
/*
Allocate next image structure.
*/
image->ticks_per_second=100;
image->alpha_trait=opacity >= 0 ? BlendPixelTrait : UndefinedPixelTrait;
if ((image->columns == 0) || (image->rows == 0))
- {
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,DestroyGIFProfile);
- global_colormap=(unsigned char *) RelinquishMagickMemory(
- global_colormap);
- meta_image=DestroyImage(meta_image);
- ThrowReaderException(CorruptImageError,"NegativeOrZeroImageSize");
- }
+ ThrowReaderException(CorruptImageError,"NegativeOrZeroImageSize");
/*
Inititialize colormap.
*/
if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
- {
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,DestroyGIFProfile);
- global_colormap=(unsigned char *) RelinquishMagickMemory(
- global_colormap);
- meta_image=DestroyImage(meta_image);
- ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
- }
+ ThrowGIFException(ResourceLimitError,"MemoryAllocationFailed");
if (BitSet((int) flag,0x80) == 0)
{
/*
colormap=(unsigned char *) AcquireQuantumMemory((size_t)
MagickMax(local_colors,256),3UL*sizeof(*colormap));
if (colormap == (unsigned char *) NULL)
- {
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,DestroyGIFProfile);
- global_colormap=(unsigned char *) RelinquishMagickMemory(
- global_colormap);
- meta_image=DestroyImage(meta_image);
- ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
- }
+ ThrowGIFException(ResourceLimitError,"MemoryAllocationFailed");
(void) ResetMagickMemory(colormap,0,3*MagickMax(local_colors,256)*
sizeof(*colormap));
count=ReadBlob(image,(3*local_colors)*sizeof(*colormap),colormap);
if (count != (ssize_t) (3*local_colors))
{
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,DestroyGIFProfile);
- global_colormap=(unsigned char *) RelinquishMagickMemory(
- global_colormap);
colormap=(unsigned char *) RelinquishMagickMemory(colormap);
- meta_image=DestroyImage(meta_image);
- ThrowReaderException(CorruptImageError,
- "InsufficientImageDataInFile");
+ ThrowGIFException(CorruptImageError,"InsufficientImageDataInFile");
}
p=colormap;
for (i=0; i < (ssize_t) image->colors; i++)
else
status=DecodeImage(image,opacity,exception);
if ((image_info->ping == MagickFalse) && (status == MagickFalse))
- {
- if (profiles != (LinkedListInfo *) NULL)
- profiles=DestroyLinkedList(profiles,DestroyGIFProfile);
- global_colormap=(unsigned char *) RelinquishMagickMemory(
- global_colormap);
- meta_image=DestroyImage(meta_image);
- ThrowReaderException(CorruptImageError,"CorruptImage");
- }
+ ThrowGIFException(CorruptImageError,"CorruptImage");
duration+=image->delay*image->iterations;
if (image_info->number_scenes != 0)
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
opacity=(-1);
- status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) image->scene-
- 1,image->scene);
+ status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
+ image->scene-1,image->scene);
if (status == MagickFalse)
break;
}