Commit 7cec2411e for imagemagick.org
commit 7cec2411eb9b6c57cfd76a07619a0cfa0b5161eb
Author: Cristy <urban-warrior@imagemagick.org>
Date: Wed Dec 2 20:14:50 2026 -0500
NaN now collapses to 0.0 for RoundToUnity()
diff --git a/MagickCore/composite-private.h b/MagickCore/composite-private.h
index 8d530ea60..0753e4d7a 100644
--- a/MagickCore/composite-private.h
+++ b/MagickCore/composite-private.h
@@ -46,7 +46,10 @@ static inline double MagickOver_(const double p,const double alpha,
static inline double RoundToUnity(const double value)
{
- return(value < 0.0 ? 0.0 : (value > 1.0) ? 1.0 : value);
+ /*
+ NaN fails both comparisons and therefore collapses to 0.0.
+ */
+ return(value > 0.0 ? ((value < 1.0) ? value : 1.0) : 0.0);
}
static inline void CompositePixelOver(const Image *image,const PixelInfo *p,
@@ -132,7 +135,7 @@ static inline void CompositePixelInfoOver(const PixelInfo *p,const double alpha,
Compose pixel p over pixel q with the given opacities.
*/
Sa=QuantumScale*alpha;
- Da=QuantumScale*beta,
+ Da=QuantumScale*beta;
gamma=Sa+Da-Sa*Da;
composite->alpha=(double) QuantumRange*RoundToUnity(gamma);
gamma=MagickSafeReciprocal(gamma);
@@ -210,7 +213,6 @@ static inline MagickBooleanType GetCompositeClipToSelf(
case ChangeMaskCompositeOp:
{
return(MagickFalse);
- break;
}
default:
break;