1 Star 0 Fork 71

yoo/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
tools-avoid-potential-null-pointer-dereference-by-GC.patch 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
From d02aeaf7c2b2e6038dd5967fddd9339480b7a25e Mon Sep 17 00:00:00 2001
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
Date: Thu, 13 Aug 2020 16:03:45 +0200
Subject: [PATCH 045/108] tools: avoid potential null pointer dereference by
GCC 10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
GCC 10 complains about "arg" possibly being a NULL dereference.
Even though it might be a false positive, we can easily avoid it.
Avoiding
../tools/vsh.c: In function ‘vshCommandOptStringReq’:
../tools/vsh.c:1034:19: error: potential null pointer dereference [-Werror=null-dereference]
1034 | else if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
| ~~~^~~~~~
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
(cherry picked from commit e2bd2af6e4f9323cf732563b430ef02e075fc804)
---
tools/vsh.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/vsh.c b/tools/vsh.c
index 58bb1e6a3c..65f4a48d62 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -1034,7 +1034,7 @@ vshCommandOptStringReq(vshControl *ctl,
/* this should not be propagated here, just to be sure */
if (ret == -1)
error = N_("Mandatory option not present");
- else if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
+ else if (arg && !*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
error = N_("Option argument is empty");
if (error) {
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mdLUbG/libvirt.git
git@gitee.com:mdLUbG/libvirt.git
mdLUbG
libvirt
libvirt
master

搜索帮助