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