Blame SOURCES/0078-Check-that-pointers-are-not-NULL-before-dereferencin.patch

af5b3d
From c3d6d7dd1feb5a7f02778304a5233cf882c651c4 Mon Sep 17 00:00:00 2001
af5b3d
From: Javier Martinez Canillas <javierm@redhat.com>
af5b3d
Date: Fri, 15 Mar 2019 10:14:42 +0100
af5b3d
Subject: [PATCH] Check that pointers are not NULL before dereferencing them
af5b3d
af5b3d
The coverity scan complains that the argValueMatch() function derefences
af5b3d
the chptra and chptrb pointers when these may be NULL. That's not really
af5b3d
true since the function first checks if both aren't NULL and then only
af5b3d
dereferences one when the other is NULL.
af5b3d
af5b3d
But still this confuses coverity, so to make it happy let's just check
af5b3d
if the pointer isn't NULL before derefencing them.
af5b3d
af5b3d
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
af5b3d
---
af5b3d
 grubby.c | 4 ++--
af5b3d
 1 file changed, 2 insertions(+), 2 deletions(-)
af5b3d
af5b3d
diff --git a/grubby.c b/grubby.c
af5b3d
index 947b45895fc..9c506aeb438 100644
af5b3d
--- a/grubby.c
af5b3d
+++ b/grubby.c
af5b3d
@@ -3761,9 +3761,9 @@ static int argValueMatch(const char *one, const char *two)
af5b3d
 
af5b3d
 	if (!chptra && !chptrb)
af5b3d
 		return 0;
af5b3d
-	else if (!chptra)
af5b3d
+	else if (!chptra && chptrb)
af5b3d
 		return *chptrb - 0;
af5b3d
-	else if (!chptrb)
af5b3d
+	else if (!chptrb && chptra)
af5b3d
 		return 0 - *chptra;
af5b3d
 	else
af5b3d
 		return strcmp(chptra, chptrb);
af5b3d
-- 
af5b3d
2.20.1
af5b3d