fix memory leaks in yajl_tree_parse

This commit is contained in:
fuanan 2022-02-12 10:21:43 +08:00
parent 224bd92a52
commit 9b422546dd
2 changed files with 31 additions and 1 deletions

View File

@ -0,0 +1,26 @@
From 23a122eddaa28165a6c219000adcc31ff9a8a698 Mon Sep 17 00:00:00 2001
From: "zhang.jiujiu" <282627424@qq.com>
Date: Tue, 7 Dec 2021 22:37:02 +0800
Subject: [PATCH] fix memory leaks
---
src/yajl_tree.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/yajl_tree.c b/src/yajl_tree.c
index b9e6604..0e7bde9 100644
--- a/src/yajl_tree.c
+++ b/src/yajl_tree.c
@@ -456,6 +456,9 @@ yajl_val yajl_tree_parse (const char *input,
yajl_tree_free(v);
}
yajl_free (handle);
+ //If the requested memory is not released in time, it will cause memory leakage
+ if(ctx.root)
+ yajl_tree_free(ctx.root);
return NULL;
}
--
1.8.3.1

View File

@ -1,6 +1,6 @@
Name: yajl
Version: 2.1.0
Release: 14
Release: 15
Summary: Yet Another JSON Library
License: ISC
URL: http://lloyd.github.com/yajl/
@ -11,6 +11,7 @@ Patch2: yajl-2.1.0-pkgconfig-includedir.patch
Patch3: yajl-2.1.0-test-location.patch
Patch4: yajl-2.1.0-dynlink-binaries.patch
Patch5: yajl-2.1.0-fix-memory-leak.patch
Patch6: backport-fix-memory-leaks.patch
BuildRequires: cmake gcc
@ -67,6 +68,9 @@ cd ../api
%{_libdir}/libyajl_s.a
%changelog
* Sat Feb 12 2022 fuanan <fuanan3@h-partners.com> - 2.1.0-15
- fix memory leaks in yajl_tree_parse
* Tue Jun 8 2021 panxiaohe<panxiaohe@huawei.com> - 2.1.0-14
- add gcc to BuildRequires