Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
do not attempt to write a null image list (thanks to Vinay Rohila)
  • Loading branch information
Cristy committed Apr 3, 2022
1 parent 469219c commit 716496e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
3 changes: 2 additions & 1 deletion MagickWand/operation.c
Expand Up @@ -4923,7 +4923,8 @@ WandPrivate void CLINoImageOperator(MagickCLI *cli_wand,
(void) DeleteImageRegistry(key);
write_images=CloneImageList(_images,_exception);
write_info=CloneImageInfo(_image_info);
(void) WriteImages(write_info,write_images,arg1,_exception);
if (write_images != (Image *) NULL)
(void) WriteImages(write_info,write_images,arg1,_exception);
write_info=DestroyImageInfo(write_info);
write_images=DestroyImageList(write_images);
break;
Expand Down
30 changes: 14 additions & 16 deletions coders/tim2.c
Expand Up @@ -60,8 +60,7 @@
#include "MagickCore/static.h"
#include "MagickCore/string_.h"
#include "MagickCore/module.h"



/*
Typedef declarations
*/
Expand Down Expand Up @@ -123,8 +122,7 @@ typedef enum
RGB24=1,
RGBA16=2,
} TIM2ColorEncoding;



/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
Expand All @@ -142,7 +140,8 @@ typedef enum
%
% The format of the ReadTIM2Image method is:
%
% Image *ReadTIM2Image(const ImageInfo *image_info,ExceptionInfo *exception)
% Image *ReadTIM2Image(const ImageInfo *image_info,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
Expand Down Expand Up @@ -600,13 +599,13 @@ static MagickBooleanType ReadTIM2ImageData(const ImageInfo *image_info,
image_info->filename);
break;
}
if (csm==CSM1)
if (csm == CSM1)
{
PixelInfo
*oldColormap;

oldColormap=(PixelInfo *) AcquireQuantumMemory((size_t)(image->colors)+1,
sizeof(*image->colormap));
oldColormap=(PixelInfo *) AcquireQuantumMemory((size_t)(image->colors)+
1,sizeof(*image->colormap));
if (oldColormap == (PixelInfo *) NULL)
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image_info->filename);
Expand All @@ -617,7 +616,8 @@ static MagickBooleanType ReadTIM2ImageData(const ImageInfo *image_info,
return(status);
}

static Image *ReadTIM2Image(const ImageInfo *image_info,ExceptionInfo *exception)
static Image *ReadTIM2Image(const ImageInfo *image_info,
ExceptionInfo *exception)
{
Image
*image;
Expand All @@ -626,6 +626,7 @@ static Image *ReadTIM2Image(const ImageInfo *image_info,ExceptionInfo *exception
status;

ssize_t
i,
str_read;

TIM2FileHeader
Expand Down Expand Up @@ -685,7 +686,7 @@ static Image *ReadTIM2Image(const ImageInfo *image_info,ExceptionInfo *exception
*/
if (file_header.image_count != 1)
ThrowReaderException(CoderError,"NumberOfImagesIsNotSupported");
for (int i=0; i < file_header.image_count; ++i)
for (i=0; i < (ssize_t) file_header.image_count; i++)
{
char
clut_depth,
Expand Down Expand Up @@ -780,8 +781,7 @@ static Image *ReadTIM2Image(const ImageInfo *image_info,ExceptionInfo *exception
break;
}
image=SyncNextImageInList(image);
status=SetImageProgress(image,LoadImagesTag,image->scene-1,
image->scene);
status=SetImageProgress(image,LoadImagesTag,image->scene-1,image->scene);
if (status == MagickFalse)
break;
}
Expand All @@ -790,8 +790,7 @@ static Image *ReadTIM2Image(const ImageInfo *image_info,ExceptionInfo *exception
return(DestroyImageList(image));
return(GetFirstImageInList(image));
}



/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
Expand Down Expand Up @@ -825,8 +824,7 @@ ModuleExport size_t RegisterTIM2Image(void)
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}



/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
Expand Down

0 comments on commit 716496e

Please sign in to comment.