1 Star 0 Fork 71

lIshaohui/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
locking-Resolve-mem-leak-in-virLockDaemonPreExecRest.patch 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
From 3542d88e097199e80419ebcb1a82b68cc71d3e2b Mon Sep 17 00:00:00 2001
From: John Ferlan <jferlan@redhat.com>
Date: Wed, 2 Dec 2020 07:43:20 -0500
Subject: [PATCH 021/108] locking: Resolve mem leak in
virLockDaemonPreExecRestart
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Initialize and free @magic since virJSONValueObjectAppendString
does not free it for us eventually.
Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 6f0418173b5567d17dba43247efc058f0318485b)
---
src/locking/lock_daemon.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 3d33995beb..9bf505c939 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -722,7 +722,7 @@ virLockDaemonPreExecRestart(const char *state_file,
char *state = NULL;
int ret = -1;
virJSONValuePtr object = virJSONValueNewObject();
- char *magic;
+ char *magic = NULL;
virHashKeyValuePairPtr pairs = NULL, tmp;
virJSONValuePtr lockspaces;
@@ -770,10 +770,8 @@ virLockDaemonPreExecRestart(const char *state_file,
if (!(magic = virLockDaemonGetExecRestartMagic()))
goto cleanup;
- if (virJSONValueObjectAppendString(object, "magic", magic) < 0) {
- VIR_FREE(magic);
+ if (virJSONValueObjectAppendString(object, "magic", magic) < 0)
goto cleanup;
- }
if (!(state = virJSONValueToString(object, true)))
goto cleanup;
@@ -797,6 +795,7 @@ virLockDaemonPreExecRestart(const char *state_file,
abort(); /* This should be impossible to reach */
cleanup:
+ VIR_FREE(magic);
VIR_FREE(pairs);
VIR_FREE(state);
virJSONValueFree(object);
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/li-shaohui/libvirt.git
git@gitee.com:li-shaohui/libvirt.git
li-shaohui
libvirt
libvirt
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385