GraphicsMagick: MAT InsertComplexDoubleRow()/InsertComplexFloatR...
GraphicsMagick Commits <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.11451.1682782499.1830.graphicsmagick-commit@lists.sourceforge.net> |
changeset d4264d9a4d85 in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=d4264d9a4d85 summary: MAT InsertComplexDoubleRow()/InsertComplexFloatRow() treat NaN as 0.0 diffstat: ChangeLog | 5 +++++ coders/mat.c | 10 +++++++++- www/Changelog.html | 8 ++++++++ 3 files changed, 22 insertions(+), 1 deletions(-) diffs (78 lines): diff -r ca23f27fe474 -r d4264d9a4d85 ChangeLog --- a/ChangeLog Sat Apr 29 10:13:35 2023 -0500 +++ b/ChangeLog Sat Apr 29 10:34:47 2023 -0500 @@ -1,5 +1,10 @@ 2023-04-29 Bob Friesenhahn <[email protected]> + * coders/mat.c (InsertComplexDoubleRow): If computed f is nan, + then use 0.0. Addresses SourceForge issue #708 "Undefined + behavior while converting negative infinity to integer". + (InsertComplexFloatRow): If computed f is nan, then use 0.0. + * magick/attribute.c (GenerateEXIFAttribute): Assure that float and double values are suitably alligned. Addresses SourceForge issue #709 "Undefined behavior while loading a value of type float diff -r ca23f27fe474 -r d4264d9a4d85 coders/mat.c --- a/coders/mat.c Sat Apr 29 10:13:35 2023 -0500 +++ b/coders/mat.c Sat Apr 29 10:34:47 2023 -0500 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2022 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in @@ -171,6 +171,8 @@ if (*p > 0) { f = (*p / MaxVal) * (Quantum)(MaxRGB - q->red); /* first multiplier should be in a range <0;1> */ + if (isnan(f)) + f=0.0; /*if(f<0) f=0; */ if (f + q->red >= MaxRGB) q->red = MaxRGB; @@ -185,6 +187,8 @@ if (*p < 0) { f = (*p / MinVal) * (Quantum)(MaxRGB - q->blue); /* first multiplier should be in a range <0;1>; *p<0 and MinVal<0. */ + if (isnan(f)) + f=0.0; /*if(f<0) f=0; */ if (f + q->blue >= MaxRGB) q->blue = MaxRGB; @@ -230,6 +234,8 @@ if (*p > 0) { f = (*p / MaxVal) * (Quantum)(MaxRGB - q->red); + if (isnan(f)) + f=0.0; /*if(f<0) f=0; //Only for Assert, should be commented out */ if (f + q->red < MaxRGB) q->red += (int)f; @@ -244,6 +250,8 @@ if (*p < 0) { f = (*p / MinVal) * (Quantum)(MaxRGB - q->blue); /* f is positive only <0; inf> */ + if (isnan(f)) + f=0.0; /*if(f<0) f=0; //Only for Assert, should be commented out */ if (f + q->blue < MaxRGB) q->blue += (int) f; diff -r ca23f27fe474 -r d4264d9a4d85 www/Changelog.html --- a/www/Changelog.html Sat Apr 29 10:13:35 2023 -0500 +++ b/www/Changelog.html Sat Apr 29 10:34:47 2023 -0500 @@ -40,6 +40,14 @@ <p>2023-04-29 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> <blockquote> <ul class="simple"> +<li><p>coders/mat.c (InsertComplexDoubleRow): If computed f is nan, +then use 0.0. Addresses SourceForge issue #708 "Undefined +behavior while converting negative infinity to integer". +(InsertComplexFloatRow): If computed f is nan, then use 0.0.</p></li> +<li><p>magick/attribute.c (GenerateEXIFAttribute): Assure that float +and double values are suitably alligned. Addresses SourceForge +issue #709 "Undefined behavior while loading a value of type float +from an unaligned address".</p></li> <li><p>coders/tiff.c (ReadTIFFImage): Validate that TIFFGetField() did return count and text rather than just relying on its return status. Addresses SourceForge issue #710 "Undefined behavior