Coverity complained colors could be left uninitialized.
authorTony Cook <tony@develop-help.com>
Tue, 1 Jan 2019 01:04:30 +0000 (12:04 +1100)
committerTony Cook <tony@develop-help.com>
Tue, 1 Jan 2019 01:04:30 +0000 (12:04 +1100)
Changes
image.c

diff --git a/Changes b/Changes
index 2554022..bfb3c68 100644 (file)
--- a/Changes
+++ b/Changes
@@ -37,6 +37,10 @@ Coverity finally finished a build, fix a few problems:
    that function with inconsistent parameters, but a
    belt-and-suspenders check was added.
 
+ - Coverity complained a call to i_getcolors(), used by the
+   implementation of the is_bilevel() method could leave the fetched
+   colors uninitialized.  Added a return value check.
+
 Imager 1.008 - 31 Dec 2018
 ============
 
diff --git a/image.c b/image.c
index 3329003..cdfa2ed 100644 (file)
--- a/image.c
+++ b/image.c
@@ -1802,7 +1802,8 @@ i_img_is_monochrome(i_img *im, int *zero_is_white) {
   if (im->type == i_palette_type
       && i_colorcount(im) == 2) {
     i_color colors[2];
-    i_getcolors(im, 0, colors, 2);
+    if (!i_getcolors(im, 0, colors, 2))
+      return 0;
     if (im->channels == 3) {
       if (colors[0].rgb.r == 255 && 
           colors[0].rgb.g == 255 &&