|
 |
15c305 |
From e2bd2af6e4f9323cf732563b430ef02e075fc804 Mon Sep 17 00:00:00 2001
|
|
 |
15c305 |
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
 |
15c305 |
Date: Thu, 13 Aug 2020 16:03:45 +0200
|
|
 |
15c305 |
Subject: [PATCH] tools: avoid potential null pointer dereference by GCC 10
|
|
 |
15c305 |
MIME-Version: 1.0
|
|
 |
15c305 |
Content-Type: text/plain; charset=UTF-8
|
|
 |
15c305 |
Content-Transfer-Encoding: 8bit
|
|
 |
15c305 |
|
|
 |
15c305 |
GCC 10 complains about "arg" possibly being a NULL dereference.
|
|
 |
15c305 |
Even though it might be a false positive, we can easily avoid it.
|
|
 |
15c305 |
|
|
 |
15c305 |
Avoiding
|
|
 |
15c305 |
../tools/vsh.c: In function ‘vshCommandOptStringReq’:
|
|
 |
15c305 |
../tools/vsh.c:1034:19: error: potential null pointer dereference [-Werror=null-dereference]
|
|
 |
15c305 |
1034 | else if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
|
|
 |
15c305 |
| ~~~^~~~~~
|
|
 |
15c305 |
|
|
 |
15c305 |
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
 |
15c305 |
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
|
|
 |
15c305 |
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
 |
15c305 |
---
|
|
 |
15c305 |
tools/vsh.c | 2 +-
|
|
 |
15c305 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
 |
15c305 |
|
|
 |
15c305 |
diff --git a/tools/vsh.c b/tools/vsh.c
|
|
 |
15c305 |
index 5e2e3ac219..11f493f969 100644
|
|
 |
15c305 |
--- a/tools/vsh.c
|
|
 |
15c305 |
+++ b/tools/vsh.c
|
|
 |
15c305 |
@@ -1031,7 +1031,7 @@ vshCommandOptStringReq(vshControl *ctl,
|
|
 |
15c305 |
/* this should not be propagated here, just to be sure */
|
|
 |
15c305 |
if (ret == -1)
|
|
 |
15c305 |
error = N_("Mandatory option not present");
|
|
 |
15c305 |
- else if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
|
|
 |
15c305 |
+ else if (arg && !*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
|
|
 |
15c305 |
error = N_("Option argument is empty");
|
|
 |
15c305 |
|
|
 |
15c305 |
if (error) {
|
|
 |
15c305 |
--
|
|
 |
15c305 |
GitLab
|
|
 |
15c305 |
|