Commit 8a2934c5d for imagemagick.org
commit 8a2934c5d58fbe60d316b601c98d3b9c63f2cfae
Author: Dirk Lemstra <dirk@lemstra.org>
Date: Fri Nov 27 23:22:32 2026 +0100
Make sure coders return false when a write fails.
diff --git a/coders/psd.c b/coders/psd.c
index bf467ef68..51733896b 100644
--- a/coders/psd.c
+++ b/coders/psd.c
@@ -3290,6 +3290,8 @@ static size_t WritePSDChannels(const PSDInfo *psd_info,
(ssize_t) channels);
offset_length=(layer->rows*(psd_info->version == 1 ? 2 : 4));
}
+ if (total_length == 0)
+ return(0);
size_offset+=2;
if ((layer->storage_class == PseudoClass) &&
(IsImageGray(layer) == MagickFalse))
@@ -4129,8 +4131,7 @@ static MagickBooleanType WritePSDImage(const ImageInfo *image_info,
image->compression=image_info->compression;
if (image->compression == ZipCompression)
image->compression=RLECompression;
- if (WritePSDChannels(&psd_info,image_info,image,image,0,MagickFalse,
- exception) == 0)
+ if (WritePSDChannels(&psd_info,image_info,image,image,0,MagickFalse,exception) == 0)
status=MagickFalse;
image->compression=compression;
}
diff --git a/coders/sixel.c b/coders/sixel.c
index 023532636..88a190f15 100644
--- a/coders/sixel.c
+++ b/coders/sixel.c
@@ -729,15 +729,20 @@ static sixel_output_t *sixel_output_create(Image *image)
return(output);
}
-static void sixel_advance(sixel_output_t *context, int nwrite)
+static MagickBooleanType sixel_advance(sixel_output_t *context, int nwrite)
{
+ if (nwrite <= 0)
+ return(MagickFalse);
if ((context->pos += nwrite) >= SIXEL_OUTPUT_PACKET_SIZE)
{
- WriteBlob(context->image,SIXEL_OUTPUT_PACKET_SIZE,context->buffer);
+ if (WriteBlob(context->image,SIXEL_OUTPUT_PACKET_SIZE,context->buffer) !=
+ SIXEL_OUTPUT_PACKET_SIZE)
+ return(MagickFalse);
memmove(context->buffer,
context->buffer + SIXEL_OUTPUT_PACKET_SIZE,(size_t)
(context->pos -= SIXEL_OUTPUT_PACKET_SIZE));
}
+ return(MagickTrue);
}
static int sixel_put_flash(sixel_output_t *const context)
@@ -752,16 +757,16 @@ static int sixel_put_flash(sixel_output_t *const context)
nwrite=(int) FormatLocaleString((char *) context->buffer+context->pos,
sizeof(context->buffer),"!%d%c",context->save_count,
(char) context->save_pixel);
- if (nwrite <= 0)
+ if (sixel_advance(context,nwrite) == MagickFalse)
return(-1);
- sixel_advance(context,nwrite);
}
else
{
for (n = 0; n < context->save_count; n++)
{
context->buffer[context->pos]=(unsigned char)context->save_pixel;
- sixel_advance(context,1);
+ if (sixel_advance(context,1) == MagickFalse)
+ return(-1);
}
}
context->save_pixel=0;
@@ -769,7 +774,7 @@ static int sixel_put_flash(sixel_output_t *const context)
return(0);
}
-static void sixel_put_pixel(sixel_output_t *const context,int pix)
+static MagickBooleanType sixel_put_pixel(sixel_output_t *const context,int pix)
{
if ((pix < 0) || (pix > '?'))
pix=0;
@@ -778,10 +783,12 @@ static void sixel_put_pixel(sixel_output_t *const context,int pix)
context->save_count++;
else
{
- sixel_put_flash(context);
+ if (sixel_put_flash(context) < 0)
+ return(MagickFalse);
context->save_pixel=pix;
context->save_count=1;
}
+ return(MagickTrue);
}
static void sixel_node_del(sixel_output_t *const context,sixel_node_t *np)
@@ -820,15 +827,19 @@ static int sixel_put_node(sixel_output_t *const context,int x,sixel_node_t *np,
{
nwrite=(int) FormatLocaleString((char *) context->buffer+
context->pos,sizeof(context->buffer),"#%d",np->color);
- sixel_advance(context,nwrite);
+ if (sixel_advance(context,nwrite) == MagickFalse)
+ return(-1);
context->active_palette=np->color;
}
}
for (; x < np->left; x++)
- sixel_put_pixel(context,0);
+ if (sixel_put_pixel(context,0) == MagickFalse)
+ return(-1);
for (; x < np->right; x++)
- sixel_put_pixel(context,np->map[x]);
- sixel_put_flash(context);
+ if (sixel_put_pixel(context,np->map[x]) == MagickFalse)
+ return(-1);
+ if (sixel_put_flash(context) < 0)
+ return(-1);
return(x);
}
@@ -887,20 +898,18 @@ static MagickBooleanType sixel_encode_impl(sixel_pixel_t *pixels,size_t width,
else
nwrite=(int) FormatLocaleString((char *) context->buffer,sizeof(context->buffer),
"\x1bP" "0;1;0" "q");
- if (nwrite <= 0)
+ if (sixel_advance(context,nwrite) == MagickFalse)
{
RelinquishNodesAndMap;
return(MagickFalse);
}
- sixel_advance(context,nwrite);
nwrite=(int) FormatLocaleString((char *) context->buffer+context->pos,
sizeof(context->buffer),"\"1;1;%d;%d",(int) width,(int) height);
- if (nwrite <= 0)
+ if (sixel_advance(context,nwrite) == MagickFalse)
{
RelinquishNodesAndMap;
return(MagickFalse);
}
- sixel_advance(context,nwrite);
if ((ncolors != 2) || (keycolor == -1))
for (n = 0; n < (ssize_t) ncolors; n++)
{
@@ -908,17 +917,11 @@ static MagickBooleanType sixel_encode_impl(sixel_pixel_t *pixels,size_t width,
nwrite=(int) FormatLocaleString((char *) context->buffer+context->pos,
sizeof(context->buffer),"#%d;2;%d;%d;%d",n,(palette[n*3+0]*100+127)/
255,(palette[n*3+1]*100+127)/255,(palette[n*3+2]*100+127)/255);
- if (nwrite <= 0)
+ if (sixel_advance(context,nwrite) == MagickFalse)
{
RelinquishNodesAndMap;
return(MagickFalse);
}
- sixel_advance(context,nwrite);
- if (nwrite <= 0)
- {
- RelinquishNodesAndMap;
- return (MagickFalse);
- }
}
for (y=i=0; y < (int) height; y++)
{
@@ -985,10 +988,19 @@ static MagickBooleanType sixel_encode_impl(sixel_pixel_t *pixels,size_t width,
{
/* DECGCR Graphics Carriage Return */
context->buffer[context->pos]='$';
- sixel_advance(context,1);
+ if (sixel_advance(context,1) == MagickFalse)
+ {
+ RelinquishNodesAndMap;
+ return(MagickFalse);
+ }
x=0;
}
x=sixel_put_node(context,x,np,(int) ncolors,keycolor);
+ if (x < 0)
+ {
+ RelinquishNodesAndMap;
+ return(MagickFalse);
+ }
sixel_node_del(context,np);
np=context->node_top;
while (np != (sixel_node_t *) NULL)
@@ -999,14 +1011,18 @@ static MagickBooleanType sixel_encode_impl(sixel_pixel_t *pixels,size_t width,
continue;
}
x=sixel_put_node(context,x,np,(int) ncolors,keycolor);
+ if (x < 0)
+ {
+ RelinquishNodesAndMap;
+ return(MagickFalse);
+ }
sixel_node_del(context,np);
np=context->node_top;
}
}
/* DECGNL Graphics Next Line */
context->buffer[context->pos]='-';
- sixel_advance(context,1);
- if (nwrite <= 0)
+ if (sixel_advance(context,1) == MagickFalse)
{
RelinquishNodesAndMap;
return(MagickFalse);
@@ -1017,22 +1033,26 @@ static MagickBooleanType sixel_encode_impl(sixel_pixel_t *pixels,size_t width,
if (context->has_8bit_control)
{
context->buffer[context->pos]=0x9c;
- sixel_advance(context,1);
+ nwrite=1;
}
else
{
context->buffer[context->pos]=0x1b;
context->buffer[context->pos+1]='\\';
- sixel_advance(context,2);
+ nwrite=2;
}
- if (nwrite <= 0)
+ if (sixel_advance(context,nwrite) == MagickFalse)
{
RelinquishNodesAndMap;
return(MagickFalse);
}
/* flush buffer */
- if (context->pos > 0)
- WriteBlob(context->image,(size_t) context->pos,context->buffer);
+ if ((context->pos > 0) &&
+ (WriteBlob(context->image,(size_t) context->pos,context->buffer) != (ssize_t) context->pos))
+ {
+ RelinquishNodesAndMap;
+ return(MagickFalse);
+ }
RelinquishNodesAndMap;
return(MagickTrue);
}
diff --git a/coders/txt.c b/coders/txt.c
index d54d1860e..ce6acd5da 100644
--- a/coders/txt.c
+++ b/coders/txt.c
@@ -752,7 +752,11 @@ static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image,
"# ImageMagick pixel enumeration: %.17g,%.17g,%.17g,%.17g,%s\n",
(double) image->columns,(double) image->rows,
(double) image->number_meta_channels,(double) range,colorspace);
- (void) WriteBlobString(image,buffer);
+ if (WriteBlobString(image,buffer) != (ssize_t) strlen(buffer))
+ {
+ status=MagickFalse;
+ break;
+ }
}
GetPixelInfo(image,&pixel);
for (y=0; y < (ssize_t) image->rows; y++)
@@ -790,7 +794,11 @@ static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image,
GetColorTuple(&pixel,MagickFalse,tuple);
(void) ConcatenateMagickString(buffer,tuple,MagickPathExtent);
(void) ConcatenateMagickString(buffer," ",MagickPathExtent);
- (void) WriteBlobString(image,buffer);
+ if (WriteBlobString(image,buffer) != (ssize_t) strlen(buffer))
+ {
+ status=MagickFalse;
+ break;
+ }
}
p+=(ptrdiff_t) GetPixelChannels(image);
continue;
@@ -813,9 +821,15 @@ static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image,
(void) QueryColorname(image,&pixel,SVGCompliance,tuple,exception);
(void) ConcatenateMagickString(buffer,tuple,MagickPathExtent);
(void) ConcatenateMagickString(buffer,"\n",MagickPathExtent);
- (void) WriteBlobString(image,buffer);
+ if (WriteBlobString(image,buffer) != (ssize_t) strlen(buffer))
+ {
+ status=MagickFalse;
+ break;
+ }
p+=(ptrdiff_t) GetPixelChannels(image);
}
+ if (status == MagickFalse)
+ break;
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
diff --git a/coders/uil.c b/coders/uil.c
index d1125f6df..9b030b325 100644
--- a/coders/uil.c
+++ b/coders/uil.c
@@ -293,13 +293,23 @@ static MagickBooleanType WriteUILImage(const ImageInfo *image_info,Image *image,
UIL header.
*/
symbol=AcquireString("");
- (void) WriteBlobString(image,"/* UIL */\n");
+ if (WriteBlobString(image,"/* UIL */\n") != 10)
+ {
+ symbol=DestroyString(symbol);
+ (void) CloseBlob(image);
+ return(MagickFalse);
+ }
GetPathComponent(image->filename,BasePath,basename);
sanitized_basename=SanitizeStringForIdentifier(basename);
(void) FormatLocaleString(buffer,MagickPathExtent,
"value\n %s_ct : color_table(\n",sanitized_basename);
sanitized_basename=DestroyString(sanitized_basename);
- (void) WriteBlobString(image,buffer);
+ if (WriteBlobString(image,buffer) != (ssize_t) strlen(buffer))
+ {
+ symbol=DestroyString(symbol);
+ (void) CloseBlob(image);
+ return(MagickFalse);
+ }
GetPixelInfo(image,&pixel);
for (i=0; i < (ssize_t) colors; i++)
{
@@ -334,11 +344,25 @@ static MagickBooleanType WriteUILImage(const ImageInfo *image_info,Image *image,
" color('%s',%s) = '%s'",name,
GetPixelInfoIntensity(image,image->colormap+i) <
((double) QuantumRange/2.0) ? "background" : "foreground",symbol);
- (void) WriteBlobString(image,buffer);
+ if (WriteBlobString(image,buffer) != (ssize_t) strlen(buffer))
+ {
+ status=MagickFalse;
+ break;
+ }
(void) FormatLocaleString(buffer,MagickPathExtent,"%s",
(i == (ssize_t) (colors-1) ? ");\n" : ",\n"));
- (void) WriteBlobString(image,buffer);
+ if (WriteBlobString(image,buffer) != (ssize_t) strlen(buffer))
+ {
+ status=MagickFalse;
+ break;
+ }
}
+ if (status == MagickFalse)
+ {
+ symbol=DestroyString(symbol);
+ (void) CloseBlob(image);
+ return(MagickFalse);
+ }
/*
Define UIL pixels.
*/
@@ -348,13 +372,22 @@ static MagickBooleanType WriteUILImage(const ImageInfo *image_info,Image *image,
" %s_icon : icon(color_table = %s_ct,\n",sanitized_basename,
sanitized_basename);
sanitized_basename=DestroyString(sanitized_basename);
- (void) WriteBlobString(image,buffer);
+ if (WriteBlobString(image,buffer) != (ssize_t) strlen(buffer))
+ {
+ symbol=DestroyString(symbol);
+ (void) CloseBlob(image);
+ return(MagickFalse);
+ }
for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
- (void) WriteBlobString(image," \"");
+ if (WriteBlobString(image," \"") != 5)
+ {
+ status=MagickFalse;
+ break;
+ }
for (x=0; x < (ssize_t) image->columns; x++)
{
k=((ssize_t) GetPixelIndex(image,p) % MaxCixels);
@@ -370,12 +403,22 @@ static MagickBooleanType WriteUILImage(const ImageInfo *image_info,Image *image,
}
symbol[j]='\0';
(void) CopyMagickString(buffer,symbol,MagickPathExtent);
- (void) WriteBlobString(image,buffer);
+ if (WriteBlobString(image,buffer) != (ssize_t) strlen(buffer))
+ {
+ status=MagickFalse;
+ break;
+ }
p+=(ptrdiff_t) GetPixelChannels(image);
}
+ if (status == MagickFalse)
+ break;
(void) FormatLocaleString(buffer,MagickPathExtent,"\"%s\n",
(y == (ssize_t) (image->rows-1) ? ");" : ","));
- (void) WriteBlobString(image,buffer);
+ if (WriteBlobString(image,buffer) != (ssize_t) strlen(buffer))
+ {
+ status=MagickFalse;
+ break;
+ }
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
diff --git a/coders/vicar.c b/coders/vicar.c
index 528c77d68..456c868b1 100644
--- a/coders/vicar.c
+++ b/coders/vicar.c
@@ -548,9 +548,6 @@ static MagickBooleanType WriteVICARImage(const ImageInfo *image_info,
size_t
length;
- ssize_t
- count;
-
unsigned char
*pixels;
@@ -595,9 +592,11 @@ static MagickBooleanType WriteVICARImage(const ImageInfo *image_info,
break;
length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
GrayQuantum,pixels,exception);
- count=WriteBlob(image,length,pixels);
- if (count != (ssize_t) length)
- break;
+ if (WriteBlob(image,length,pixels) != (ssize_t) length)
+ {
+ status=MagickFalse;
+ break;
+ }
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
diff --git a/coders/viff.c b/coders/viff.c
index 4261ad54a..c1f42aa68 100644
--- a/coders/viff.c
+++ b/coders/viff.c
@@ -1301,8 +1301,11 @@ static MagickBooleanType WriteVIFFImage(const ImageInfo *image_info,
}
}
}
- (void) WriteBlob(image,(size_t) packets,pixels);
+ if (WriteBlob(image,(size_t) packets,pixels) != (ssize_t) packets)
+ status=MagickFalse;
pixel_info=RelinquishVirtualMemory(pixel_info);
+ if (status == MagickFalse)
+ break;
if (GetNextImageInList(image) == (Image *) NULL)
break;
image=SyncNextImageInList(image);
diff --git a/coders/xbm.c b/coders/xbm.c
index 3f86ac8ac..995e74dab 100644
--- a/coders/xbm.c
+++ b/coders/xbm.c
@@ -511,6 +511,16 @@ ModuleExport void UnregisterXBMImage(void)
% o exception: return any errors or warnings in this structure.
%
*/
+static inline MagickBooleanType WriteXBMBuffer(Image *image,const char *buffer)
+{
+ size_t
+ length;
+
+ length=strlen(buffer);
+ return(WriteBlob(image,length,(const unsigned char *) buffer) ==
+ (ssize_t) length ? MagickTrue : MagickFalse);
+}
+
static MagickBooleanType WriteXBMImage(const ImageInfo *image_info,Image *image,
ExceptionInfo *exception)
{
@@ -598,12 +608,20 @@ static MagickBooleanType WriteXBMImage(const ImageInfo *image_info,Image *image,
*/
(void) FormatLocaleString(buffer,MagickPathExtent,"0x%02X, ",
(unsigned int) (byte & 0xff));
- (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
+ if (WriteXBMBuffer(image,buffer) == MagickFalse)
+ {
+ status=MagickFalse;
+ break;
+ }
count++;
if (count == 12)
{
(void) CopyMagickString(buffer,"\n ",MagickPathExtent);
- (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
+ if (WriteXBMBuffer(image,buffer) == MagickFalse)
+ {
+ status=MagickFalse;
+ break;
+ }
count=0;
};
bit=0;
@@ -611,6 +629,8 @@ static MagickBooleanType WriteXBMImage(const ImageInfo *image_info,Image *image,
}
p+=(ptrdiff_t) GetPixelChannels(image);
}
+ if (status == MagickFalse)
+ break;
if (bit != 0)
{
/*
@@ -619,12 +639,20 @@ static MagickBooleanType WriteXBMImage(const ImageInfo *image_info,Image *image,
byte>>=(8-bit);
(void) FormatLocaleString(buffer,MagickPathExtent,"0x%02X, ",
(unsigned int) (byte & 0xff));
- (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
+ if (WriteXBMBuffer(image,buffer) == MagickFalse)
+ {
+ status=MagickFalse;
+ break;
+ }
count++;
if (count == 12)
{
(void) CopyMagickString(buffer,"\n ",MagickPathExtent);
- (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
+ if (WriteXBMBuffer(image,buffer) == MagickFalse)
+ {
+ status=MagickFalse;
+ break;
+ }
count=0;
};
bit=0;
@@ -636,7 +664,8 @@ static MagickBooleanType WriteXBMImage(const ImageInfo *image_info,Image *image,
break;
}
(void) CopyMagickString(buffer,"};\n",MagickPathExtent);
- (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
+ if ((status != MagickFalse) && (WriteXBMBuffer(image,buffer) == MagickFalse))
+ status=MagickFalse;
if (CloseBlob(image) == MagickFalse)
status=MagickFalse;
return(status);
diff --git a/coders/ycbcr.c b/coders/ycbcr.c
index a95d9e42a..72bd1e65e 100644
--- a/coders/ycbcr.c
+++ b/coders/ycbcr.c
@@ -1175,7 +1175,10 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
quantum_type,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
@@ -1200,24 +1203,36 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
RedQuantum,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
GreenQuantum,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
BlueQuantum,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
if (quantum_type == RGBAQuantum)
{
length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
AlphaQuantum,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
}
if (image->previous == (Image *) NULL)
{
@@ -1243,8 +1258,13 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
RedQuantum,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
}
+ if (status == MagickFalse)
+ break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,1,5);
@@ -1260,8 +1280,13 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
GreenQuantum,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
}
+ if (status == MagickFalse)
+ break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,2,5);
@@ -1277,8 +1302,13 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
BlueQuantum,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
}
+ if (status == MagickFalse)
+ break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,3,5);
@@ -1296,9 +1326,14 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
AlphaQuantum,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
}
}
+ if (status == MagickFalse)
+ break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,5,5);
@@ -1329,8 +1364,13 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
RedQuantum,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
}
+ if (status == MagickFalse)
+ break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,1,5);
@@ -1338,7 +1378,10 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
break;
}
if (CloseBlob(image) == MagickFalse)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
AppendImageFormat("Cb",image->filename);
status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
AppendBinaryBlobMode,exception);
@@ -1356,8 +1399,13 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
GreenQuantum,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
}
+ if (status == MagickFalse)
+ break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,2,5);
@@ -1365,7 +1413,10 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
break;
}
if (CloseBlob(image) == MagickFalse)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
AppendImageFormat("Cr",image->filename);
status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
AppendBinaryBlobMode,exception);
@@ -1383,8 +1434,13 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
BlueQuantum,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
}
+ if (status == MagickFalse)
+ break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,3,5);
@@ -1394,7 +1450,10 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
if (quantum_type == RGBAQuantum)
{
if (CloseBlob(image) == MagickFalse)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
AppendImageFormat("A",image->filename);
status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
AppendBinaryBlobMode,exception);
@@ -1412,8 +1471,13 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
AlphaQuantum,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
}
+ if (status == MagickFalse)
+ break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,4,5);
@@ -1421,7 +1485,11 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
break;
}
}
- (void) CloseBlob(image);
+ if (CloseBlob(image) == MagickFalse)
+ {
+ status=MagickFalse;
+ break;
+ }
(void) CopyMagickString(image->filename,image_info->filename,
MagickPathExtent);
if (image->previous == (Image *) NULL)
@@ -1434,6 +1502,8 @@ static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
}
}
quantum_info=DestroyQuantumInfo(quantum_info);
+ if (status == MagickFalse)
+ break;
if (GetNextImageInList(image) == (Image *) NULL)
break;
image=SyncNextImageInList(image);