From f1cc2eb986dc8f4a7727bce689a17566f896fde6 Mon Sep 17 00:00:00 2001 From: Cristy Date: Fri, 17 Mar 2017 07:14:25 -0400 Subject: [PATCH] Eliminate possible but rare memory leak (bug report by Dirk) --- coders/pgx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/coders/pgx.c b/coders/pgx.c index e03981f87..04a5f2c99 100644 --- a/coders/pgx.c +++ b/coders/pgx.c @@ -376,7 +376,7 @@ static MagickBooleanType WritePGXImage(const ImageInfo *image_info,Image *image, GrayQuantum,pixels,exception); count=WriteBlob(image,length,pixels); if (count != (ssize_t) length) - ThrowWriterException(CorruptImageError,"UnableToWriteImageData"); + break; count=WriteBlob(image,(size_t) (-(ssize_t) length) & 0x01,pixels); status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, image->rows); @@ -384,6 +384,8 @@ static MagickBooleanType WritePGXImage(const ImageInfo *image_info,Image *image, break; } quantum_info=DestroyQuantumInfo(quantum_info); + if (y < (ssize_t) image->rows) + ThrowWriterException(CorruptImageError,"UnableToWriteImageData"); (void) CloseBlob(image); return(status); } -- 2.40.0