1 Star 0 Fork 71

yoo/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vshtabletest-Fix-potential-memleak.patch 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
yezengruan 提交于 2022-11-25 19:41 . sync some bugfix patches from upstream
From e210025037fbd00c81e8faa0a5339dccdc0c75a1 Mon Sep 17 00:00:00 2001
From: wangmeiyang <wangmeiyang_yewu@cmss.chinamobile.com>
Date: Thu, 24 Nov 2022 09:10:25 +0800
Subject: [PATCH 12/23] vshtabletest: Fix potential memleak
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In testVshTableNew() we test whether vshTableNew(NULL) allocates
a table. This is expected to fail (and return NULL), because
passing nothing but NULL to vshTableNew() is viewed as error.
Nevertheless, if vshTableNew() did not fail and returned an
allocated table it would be leaked.
cherry-pick from eb9bbde7721af765d88086dc3055cff092436c58
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Meiyang Wang <wangmeiyang_yewu@cmss.chinamobile.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/vshtabletest.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c
index 15369d8eb2..348f525234 100644
--- a/tests/vshtabletest.c
+++ b/tests/vshtabletest.c
@@ -33,11 +33,12 @@
static int
testVshTableNew(const void *opaque G_GNUC_UNUSED)
{
- if (vshTableNew(NULL)) {
+ vshTablePtr table = vshTableNew(NULL);
+ if (table) {
fprintf(stderr, "expected failure when passing null to vshTableNew\n");
return -1;
}
-
+ vshTableFree(table);
return 0;
}
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mdLUbG/libvirt.git
git@gitee.com:mdLUbG/libvirt.git
mdLUbG
libvirt
libvirt
master

搜索帮助