GraphicsMagick: DetachBlob(): Fix Coverity issue 381869 "Null po...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.14659.1667939942.1459.graphicsmagick-commit@lists.sourceforge.net>
changeset 6c26fcb005d1 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=6c26fcb005d1
summary: DetachBlob(): Fix Coverity issue 381869 "Null pointer dereferences (FORWARD_NULL)"

diffstat:

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

diffs (39 lines):

diff -r d3f42947a065 -r 6c26fcb005d1 ChangeLog
--- a/ChangeLog	Tue Nov 08 14:26:49 2022 -0600
+++ b/ChangeLog	Tue Nov 08 14:38:48 2022 -0600
@@ -1,5 +1,9 @@
 2022-11-08  Bob Friesenhahn  <[email protected]>
 
+	* magick/blob.c (DetachBlob): Do not dereference blob_info->data
+	if it is null.  Addresses Coverity issue 381869 "Null pointer
+	dereferences (FORWARD_NULL)".
+
 	* coders/jpeg.c (FreeMagickClientData): Fix Coverity issue 381870
 	"Null pointer dereferences".
 
diff -r d3f42947a065 -r 6c26fcb005d1 magick/blob.c
--- a/magick/blob.c	Tue Nov 08 14:26:49 2022 -0600
+++ b/magick/blob.c	Tue Nov 08 14:38:48 2022 -0600
@@ -1283,7 +1283,8 @@
  assert(blob_info != (BlobInfo *) NULL);
   if (blob_info->mapped)
     {
-      (void) UnmapBlob(blob_info->data,blob_info->length);
+      if (blob_info->data != (unsigned char *) NULL)
+        (void) UnmapBlob(blob_info->data,blob_info->length);
       LiberateMagickResource(MapResource,blob_info->length);
     }
   blob_info->mapped=MagickFalse;
diff -r d3f42947a065 -r 6c26fcb005d1 www/Changelog.html
--- a/www/Changelog.html	Tue Nov 08 14:26:49 2022 -0600
+++ b/www/Changelog.html	Tue Nov 08 14:38:48 2022 -0600
@@ -40,6 +40,9 @@
 <p>2022-11-08  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>magick/blob.c (DetachBlob): Do not dereference blob_info-&gt;data
+if it is null.  Addresses Coverity issue 381869 &quot;Null pointer
+dereferences (FORWARD_NULL)&quot;.</p></li>
 <li><p>coders/jpeg.c (FreeMagickClientData): Fix Coverity issue 381870
 &quot;Null pointer dereferences&quot;.</p></li>
 <li><p>magick/export.c (ExportViewPixelArea): Fix Coverity issue 381871
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.