Commit 4edd9a7d1 for imagemagick.org
commit 4edd9a7d1161902d372ce696e4323bf6dd0ba450
Author: Cristy <urban-warrior@imagemagick.org>
Date: Fri Dec 4 19:03:23 2026 -0500
WriteDEBUGImage now reports failure when GetVirtualPixels() fails
diff --git a/coders/debug.c b/coders/debug.c
index 20f74038b..148844aff 100644
--- a/coders/debug.c
+++ b/coders/debug.c
@@ -145,7 +145,8 @@ ModuleExport void UnregisterDEBUGImage(void)
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% WriteDEBUGImage writes the image pixel values with 20 places of precision.
+% WriteDEBUGImage writes the image pixel values with 17 significant digits,
+% enough to round-trip any double exactly.
%
% The format of the WriteDEBUGImage method is:
%
@@ -195,6 +196,8 @@ static MagickBooleanType WriteDEBUGImage(const ImageInfo *image_info,
assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickCoreSignature);
if (IsEventLogging() != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
status=OpenBlob(image_info,image,WriteBlobMode,exception);
@@ -204,8 +207,13 @@ static MagickBooleanType WriteDEBUGImage(const ImageInfo *image_info,
number_scenes=GetImageListLength(image);
do
{
- (void) CopyMagickString(colorspace,CommandOptionToMnemonic(
- MagickColorspaceOptions,(ssize_t) image->colorspace),MagickPathExtent);
+ const char
+ *mnemonic;
+
+ mnemonic=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
+ image->colorspace);
+ (void) CopyMagickString(colorspace,mnemonic != (const char *) NULL ?
+ mnemonic : "undefined",MagickPathExtent);
LocaleLower(colorspace);
image->depth=GetImageQuantumDepth(image,MagickTrue);
if (image->alpha_trait != UndefinedPixelTrait)
@@ -220,21 +228,24 @@ static MagickBooleanType WriteDEBUGImage(const ImageInfo *image_info,
{
p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
- break;
+ {
+ status=MagickFalse;
+ break;
+ }
for (x=0; x < (ssize_t) image->columns; x++)
{
(void) FormatLocaleString(buffer,MagickPathExtent,"%.17g,%.17g: ",(double)
x,(double) y);
(void) WriteBlobString(image,buffer);
GetPixelInfoPixel(image,p,&pixel);
- (void) FormatLocaleString(tuple,MagickPathExtent,"%.17g,%.17g,%.17g ",
+ (void) FormatLocaleString(tuple,MagickPathExtent,"%.17g,%.17g,%.17g",
(double) pixel.red,(double) pixel.green,(double) pixel.blue);
if (pixel.colorspace == CMYKColorspace)
{
char
black[MagickPathExtent];
- (void) FormatLocaleString(black,MagickPathExtent,",%.17g ",
+ (void) FormatLocaleString(black,MagickPathExtent,",%.17g",
(double) pixel.black);
(void) ConcatenateMagickString(tuple,black,MagickPathExtent);
}
@@ -243,7 +254,7 @@ static MagickBooleanType WriteDEBUGImage(const ImageInfo *image_info,
char
alpha[MagickPathExtent];
- (void) FormatLocaleString(alpha,MagickPathExtent,",%.17g ",
+ (void) FormatLocaleString(alpha,MagickPathExtent,",%.17g",
(double) pixel.alpha);
(void) ConcatenateMagickString(tuple,alpha,MagickPathExtent);
}
@@ -256,6 +267,8 @@ static MagickBooleanType WriteDEBUGImage(const ImageInfo *image_info,
if (status == MagickFalse)
break;
}
+ if (status == MagickFalse)
+ break;
if (GetNextImageInList(image) == (Image *) NULL)
break;
image=SyncNextImageInList(image);