Here is the critical code : ( in cmyk.c)
scanline=MagickAllocateArray(unsigned char *, //163
packet_size,image->tile_info.width);
if (scanline == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
...
if (image_info->interlace == PartitionInterlace)
{
AppendImageFormat("C",image->filename);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == False)
ThrowReaderException(FileOpenError,UnableToOpenFile,image);//301
...
if (image_info->interlace == PartitionInterlace)
{
CloseBlob(image);
AppendImageFormat("M",image->filename);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == False)
ThrowReaderException(FileOpenError,UnableToOpenFile,image);//336
}
...
if (image_info->interlace == PartitionInterlace)
{
CloseBlob(image);
AppendImageFormat("Y",image->filename);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == False)
ThrowReaderException(FileOpenError,UnableToOpenFile,image);//367
}
...
if (image_info->interlace == PartitionInterlace)
{
CloseBlob(image);
AppendImageFormat("K",image->filename);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == False)
ThrowReaderException(FileOpenError,UnableToOpenFile,image);//397
}
...
if (image_info->interlace == PartitionInterlace)
{
CloseBlob(image);
AppendImageFormat("A",image->filename);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == False)
ThrowReaderException(FileOpenError,UnableToOpenFile,image);//434
}
Line 301,336,367,397,434 do not free memory about scanline, this will cause memory leak.
Credit: ADLab of Venustech
This problem is fixed by Mercurial changeset 15204:2a84c4f0f453. Thanks for the report!