2 Star 0 Fork 91

yangshicheng / systemd

forked from src-openEuler / systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-shared-json-fix-memory-leak-on-failed-normalization.patch 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
hongjinghao 提交于 2023-06-19 10:57 . sync patches from systemd community
From c1dbf637d7f5588a19b5d9ea812fee2e68a6dcfa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Mon, 9 May 2022 14:28:36 +0200
Subject: [PATCH] shared/json: fix memory leak on failed normalization
We need to increase the counter immediately after taking the ref,
otherwise we may not unref it properly if we fail before incrementing.
(cherry picked from commit 7e4be6a5845f983a299932d4ccb2c4349cf8dd52)
---
src/shared/json.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/shared/json.c b/src/shared/json.c
index dff95eda26..711aa36c87 100644
--- a/src/shared/json.c
+++ b/src/shared/json.c
@@ -4680,10 +4680,11 @@ int json_variant_normalize(JsonVariant **v) {
if (!a)
return -ENOMEM;
- for (i = 0; i < m; i++) {
+ for (i = 0; i < m; ) {
a[i] = json_variant_ref(json_variant_by_index(*v, i));
+ i++;
- r = json_variant_normalize(a + i);
+ r = json_variant_normalize(&a[i-1]);
if (r < 0)
goto finish;
}
--
2.33.0
1
https://gitee.com/yangshicheng/systemd.git
git@gitee.com:yangshicheng/systemd.git
yangshicheng
systemd
systemd
master

搜索帮助