GraphicsMagick: ReadIdentityImage(): Check the return value from...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.8081.1691595566.1439.graphicsmagick-commit@lists.sourceforge.net>
changeset 7137fc4987bd in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=7137fc4987bd
summary: ReadIdentityImage(): Check the return value from AllocateImageColormap()

diffstat:

 ChangeLog          |  4 ++++
 coders/identity.c  |  3 ++-
 www/Changelog.html |  3 +++
 3 files changed, 9 insertions(+), 1 deletions(-)

diffs (39 lines):

diff -r c569746bc87e -r 7137fc4987bd ChangeLog
--- a/ChangeLog	Wed Aug 09 10:31:43 2023 -0500
+++ b/ChangeLog	Wed Aug 09 10:39:15 2023 -0500
@@ -1,5 +1,9 @@
 2023-08-09  Bob Friesenhahn  <[email protected]>
 
+	* coders/identity.c (ReadIdentityImage): Check the return value
+	from AllocateImageColormap().  Addresses Coverity 384802
+	"Unchecked return value".
+
 	* magick/utility.c (ExpandFilename): sysconf() can return a
 	negative value (e.g. -1).  Verify that the value is greater than 0
 	before using it.  Addresses Coverity 384798 "Out-of-bounds
diff -r c569746bc87e -r 7137fc4987bd coders/identity.c
--- a/coders/identity.c	Wed Aug 09 10:31:43 2023 -0500
+++ b/coders/identity.c	Wed Aug 09 10:39:15 2023 -0500
@@ -97,7 +97,8 @@
   image->columns=image->rows=order*order*order;
 
   if (image->columns*image->rows <= MaxColormapSize)
-    AllocateImageColormap(image,(const unsigned long) image->columns*image->rows);
+    if (!AllocateImageColormap(image,(const unsigned long) image->columns*image->rows))
+      ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
 
 #if defined(HAVE_OPENMP)
 #  if defined(TUNE_OPENMP)
diff -r c569746bc87e -r 7137fc4987bd www/Changelog.html
--- a/www/Changelog.html	Wed Aug 09 10:31:43 2023 -0500
+++ b/www/Changelog.html	Wed Aug 09 10:39:15 2023 -0500
@@ -40,6 +40,9 @@
 <p>2023-08-09  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
+<li><p>coders/identity.c (ReadIdentityImage): Check the return value
+from AllocateImageColormap().  Addresses Coverity 384802
+&quot;Unchecked return value&quot;.</p></li>
 <li><p>magick/utility.c (ExpandFilename): sysconf() can return a
 negative value (e.g. -1).  Verify that the value is greater than 0
 before using it.  Addresses Coverity 384798 &quot;Out-of-bounds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.