From: Cristy <urban-warrior@imagemagick.org>
Date: Thu, 14 Sep 2017 11:32:01 +0000 (-0400)
Subject: ...
X-Git-Tag: 7.0.7-3~36
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=654a0fdd31cb34e34bfdb03eb360c9ab3d5fedd9;p=imagemagick

...
---

diff --git a/coders/ycbcr.c b/coders/ycbcr.c
index 585070c65..946e5e1b3 100644
--- a/coders/ycbcr.c
+++ b/coders/ycbcr.c
@@ -200,6 +200,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
   count=0;
   length=0;
   scene=0;
+  status=MagickTrue;
   do
   {
     /*
@@ -231,6 +232,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
         {
           if (count != (ssize_t) length)
             {
+              status=MagickFalse;
               ThrowFileException(exception,CorruptImageError,
                 "UnexpectedEndOfFile",image->filename);
               break;
@@ -304,6 +306,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
           {
             if (count != (ssize_t) length)
               {
+                status=MagickFalse;
                 ThrowFileException(exception,CorruptImageError,
                   "UnexpectedEndOfFile",image->filename);
                 break;
@@ -388,6 +391,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
         {
           if (count != (ssize_t) length)
             {
+              status=MagickFalse;
               ThrowFileException(exception,CorruptImageError,
                 "UnexpectedEndOfFile",image->filename);
               break;
@@ -432,6 +436,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
         {
           if (count != (ssize_t) length)
             {
+              status=MagickFalse;
               ThrowFileException(exception,CorruptImageError,
                 "UnexpectedEndOfFile",image->filename);
               break;
@@ -476,6 +481,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
         {
           if (count != (ssize_t) length)
             {
+              status=MagickFalse;
               ThrowFileException(exception,CorruptImageError,
                 "UnexpectedEndOfFile",image->filename);
               break;
@@ -522,6 +528,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
             {
               if (count != (ssize_t) length)
                 {
+                  status=MagickFalse;
                   ThrowFileException(exception,CorruptImageError,
                     "UnexpectedEndOfFile",image->filename);
                   break;
@@ -596,6 +603,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
               GetQuantumPixels(quantum_info),&count);
             if (count != (ssize_t) length)
               {
+                status=MagickFalse;
                 ThrowFileException(exception,CorruptImageError,
                   "UnexpectedEndOfFile",image->filename);
                 break;
@@ -607,6 +615,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
         {
           if (count != (ssize_t) length)
             {
+              status=MagickFalse;
               ThrowFileException(exception,CorruptImageError,
                 "UnexpectedEndOfFile",image->filename);
               break;
@@ -664,6 +673,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
               GetQuantumPixels(quantum_info),&count);
             if (count != (ssize_t) length)
               {
+                status=MagickFalse;
                 ThrowFileException(exception,CorruptImageError,
                   "UnexpectedEndOfFile",image->filename);
                 break;
@@ -675,6 +685,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
         {
           if (count != (ssize_t) length)
             {
+              status=MagickFalse;
               ThrowFileException(exception,CorruptImageError,
                 "UnexpectedEndOfFile",image->filename);
               break;
@@ -732,6 +743,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
               GetQuantumPixels(quantum_info),&count);
             if (count != (ssize_t) length)
               {
+                status=MagickFalse;
                 ThrowFileException(exception,CorruptImageError,
                   "UnexpectedEndOfFile",image->filename);
                 break;
@@ -743,6 +755,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
         {
           if (count != (ssize_t) length)
             {
+              status=MagickFalse;
               ThrowFileException(exception,CorruptImageError,
                 "UnexpectedEndOfFile",image->filename);
               break;
@@ -802,6 +815,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
                   GetQuantumPixels(quantum_info),&count);
                 if (count != (ssize_t) length)
                   {
+                    status=MagickFalse;
                     ThrowFileException(exception,CorruptImageError,
                       "UnexpectedEndOfFile",image->filename);
                     break;
@@ -813,6 +827,7 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
             {
               if (count != (ssize_t) length)
                 {
+                  status=MagickFalse;
                   ThrowFileException(exception,CorruptImageError,
                     "UnexpectedEndOfFile",image->filename);
                   break;
@@ -893,6 +908,8 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
   quantum_info=DestroyQuantumInfo(quantum_info);
   canvas_image=DestroyImage(canvas_image);
   (void) CloseBlob(image);
+  if (status == MagickFalse)
+    return(DestroyImageList(image));
   return(GetFirstImageInList(image));
 }