Commit 4cfcb7328 for imagemagick.org
commit 4cfcb732872c57dc6a86c03a20033446fe967014
Author: Cristy <urban-warrior@imagemagick.org>
Date: Fri Dec 4 10:28:51 2026 -0500
canvas size grows to max(current size,offset+tile size), so offset tiles are no longer rejected
diff --git a/coders/pict.c b/coders/pict.c
index 4af883ec5..8a66cf9dd 100644
--- a/coders/pict.c
+++ b/coders/pict.c
@@ -1530,27 +1530,40 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
columns,
rows;
- columns=MagickMax(image->columns,tile_image->columns);
- rows=MagickMax(image->rows,tile_image->rows);
+ /*
+ Enlarge the canvas, if necessary, to hold the tile at its offset.
+ */
+ columns=MagickMax(image->columns,(size_t) frame.left+
+ tile_image->columns);
+ rows=MagickMax(image->rows,(size_t) frame.top+tile_image->rows);
if ((columns != image->columns) || (rows != image->rows))
{
+ Image
+ *canvas;
+
+ canvas=CloneImage(image,0,0,MagickTrue,exception);
+ if (canvas == (Image *) NULL)
+ ThrowPICTException(ResourceLimitError,"MemoryAllocationFailed");
/*
- Clear added pixels them so they cannot leak process memory.
+ Clear the enlarged canvas so it cannot leak process memory,
+ then restore the prior contents.
*/
- if ((SetImageExtent(image,columns,rows,exception) == MagickFalse) ||
- (ResetImagePixels(image,exception) == MagickFalse))
+ status=SetImageExtent(image,columns,rows,exception);
+ if (status != MagickFalse)
+ status=ResetImagePixels(image,exception);
+ if (status != MagickFalse)
+ status=CompositeImage(image,canvas,CopyCompositeOp,MagickTrue,
+ 0,0,exception);
+ canvas=DestroyImage(canvas);
+ if (status == MagickFalse)
ThrowPICTException(ResourceLimitError,"UnableToReadImageData");
}
}
- /*
- The tile must lie entirely within the canvas.
- */
- if ((((MagickSizeType) frame.left+tile_image->columns) > image->columns) ||
- (((MagickSizeType) frame.top+tile_image->rows) > image->rows))
- ThrowPICTException(CorruptImageError,"ImproperImageHeader");
- if (TransformImageColorspace(image,tile_image->colorspace,exception) == MagickFalse)
+ if (TransformImageColorspace(image,tile_image->colorspace,
+ exception) == MagickFalse)
ThrowPICTException(CorruptImageError,"UnableToReadImageData");
- if (CompositeImage(image,tile_image,CopyCompositeOp,MagickTrue,(ssize_t) frame.left,(ssize_t) frame.top,exception) == MagickFalse)
+ if (CompositeImage(image,tile_image,CopyCompositeOp,MagickTrue,
+ (ssize_t) frame.left,(ssize_t) frame.top,exception) == MagickFalse)
ThrowPICTException(CorruptImageError,"UnableToReadImageData");
image->compression=tile_image->compression;
tile_image=DestroyImage(tile_image);