加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
util-virIdentitySetCurrent-only-unref-the-old-identi.patch 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
From 8a06893a603f32791899314fd16afdd424e77e6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Fri, 3 Sep 2021 16:04:44 +0200
Subject: [PATCH 100/108] util: virIdentitySetCurrent: only unref the old
identity on success
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In the unlikely case that we were unable to set the new
identity, we would unref the old one even though it still
could be in the thread-local storage.
Fixes: c6825d88137cb8e4debdf4310e45ee23cb5698c0
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit a082c462290bfa8fd4cbbc41c1d6040864228c78)
---
src/util/viridentity.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/util/viridentity.c b/src/util/viridentity.c
index 2cb9042a84..e133d29e7d 100644
--- a/src/util/viridentity.c
+++ b/src/util/viridentity.c
@@ -122,7 +122,7 @@ virIdentityPtr virIdentityGetCurrent(void)
*/
int virIdentitySetCurrent(virIdentityPtr ident)
{
- g_autoptr(virIdentity) old = NULL;
+ virIdentity *old = NULL;
if (virIdentityInitialize() < 0)
return -1;
@@ -138,6 +138,8 @@ int virIdentitySetCurrent(virIdentityPtr ident)
return -1;
}
+ if (old)
+ g_object_unref(old);
return 0;
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化