From dfefe8de5068a547ae4097c69456f02f93935164 Mon Sep 17 00:00:00 2001 From: Cristy Date: Fri, 8 Sep 2017 06:23:10 -0400 Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/740 --- coders/mat.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/coders/mat.c b/coders/mat.c index c7edc46a8..d9f150763 100644 --- a/coders/mat.c +++ b/coders/mat.c @@ -999,14 +999,35 @@ MATLAB_KO: case 8: z2=z=1; break; /* 2D matrix*/ case 12: z2=z = ReadBlobXXXLong(image2); /* 3D matrix RGB*/ (void) ReadBlobXXXLong(image2); - if(z!=3) ThrowReaderException(CoderError, "MultidimensionalMatricesAreNotSupported"); + if(z!=3) + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CoderError, + "MultidimensionalMatricesAreNotSupported"); + } break; case 16: z2=z = ReadBlobXXXLong(image2); /* 4D matrix animation */ if(z!=3 && z!=1) - ThrowReaderException(CoderError, "MultidimensionalMatricesAreNotSupported"); + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CoderError, + "MultidimensionalMatricesAreNotSupported"); + } Frames = ReadBlobXXXLong(image2); if (Frames == 0) - ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + { + if (clone_info != (ImageInfo *) NULL) + clone_info=DestroyImageInfo(clone_info); + if ((image != image2) && (image2 != (Image *) NULL)) + image2=DestroyImage(image2); + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + } break; default: if (clone_info != (ImageInfo *) NULL) -- 2.40.0