add index and cmake options

1. add index for patchs;
2. add cmake options for test and binary;

Signed-off-by: haozi007 <liuhao27@huawei.com>
This commit is contained in:
haozi007 2022-06-08 07:30:51 +01:00
parent 12cd93862d
commit 0c9b212a02
9 changed files with 92 additions and 33 deletions

View File

@ -0,0 +1,27 @@
From d6d0aeb5f6432763929d4096344ec2caf6d13d89 Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Sat, 28 May 2022 10:06:46 +0100
Subject: [PATCH] fix memory leak of ctx root
Signed-off-by: haozi007 <liuhao27@huawei.com>
---
src/yajl_tree.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/yajl_tree.c b/src/yajl_tree.c
index 4b3cf2b..dc55f74 100644
--- a/src/yajl_tree.c
+++ b/src/yajl_tree.c
@@ -449,6 +449,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;
}
--
2.20.1

View File

@ -0,0 +1,54 @@
From 255917e92717c491ffb66eb63a3333682d13df60 Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Wed, 8 Jun 2022 07:27:46 +0100
Subject: [PATCH] add cmake option for test and binary
Signed-off-by: haozi007 <liuhao27@huawei.com>
---
CMakeLists.txt | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c0a9be..9cc63c5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,18 +64,27 @@ ENDIF (WIN32)
ADD_SUBDIRECTORY(src)
-ADD_SUBDIRECTORY(test)
-ADD_SUBDIRECTORY(reformatter)
-ADD_SUBDIRECTORY(verify)
+
+IF (NOT DISABLE_TEST)
+ ADD_SUBDIRECTORY(test)
+ENDIF ()
+
+IF (NOT DISABLE_BIN)
+ ADD_SUBDIRECTORY(reformatter)
+ ADD_SUBDIRECTORY(verify)
+ENDIF ()
+
ADD_SUBDIRECTORY(example)
ADD_SUBDIRECTORY(perf)
INCLUDE(YAJLDoc.cmake)
-# a test target
-ADD_CUSTOM_TARGET(test
- ./run_tests.sh ${CMAKE_CURRENT_BINARY_DIR}/test/parsing/yajl_test
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test/parsing)
+IF (NOT DISABLE_TEST)
+ # a test target
+ ADD_CUSTOM_TARGET(test
+ ./run_tests.sh ${CMAKE_CURRENT_BINARY_DIR}/test/parsing/yajl_test
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test/parsing)
-ADD_CUSTOM_TARGET(test-api ${CMAKE_CURRENT_SOURCE_DIR}/test/api/run_tests.sh
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test/api)
+ ADD_CUSTOM_TARGET(test-api ${CMAKE_CURRENT_SOURCE_DIR}/test/api/run_tests.sh
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test/api)
+ENDIF ()
--
2.20.1

View File

@ -1,26 +0,0 @@
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,17 +1,18 @@
Name: yajl
Version: 2.1.0
Release: 15
Release: 16
Summary: Yet Another JSON Library
License: ISC
URL: http://lloyd.github.com/yajl/
Source0: https://github.com/lloyd/yajl/archive/%{version}.tar.gz
Patch1: yajl-2.1.0-pkgconfig-location.patch
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
Patch1: 0001-yajl-2.1.0-pkgconfig-location.patch
Patch2: 0002-yajl-2.1.0-pkgconfig-includedir.patch
Patch3: 0003-yajl-2.1.0-test-location.patch
Patch4: 0004-yajl-2.1.0-dynlink-binaries.patch
Patch5: 0005-yajl-2.1.0-fix-memory-leak.patch
Patch6: 0006-fix-memory-leak-of-ctx-root.patch
Patch7: 0007-add-cmake-option-for-test-and-binary.patch
BuildRequires: cmake gcc
@ -68,6 +69,9 @@ cd ../api
%{_libdir}/libyajl_s.a
%changelog
* Wed Jun 8 2022 haozi007 <liuhao27@h-partners.com> - 2.1.0-16
- add index for patch and add cmake options
* Sat Feb 12 2022 fuanan <fuanan3@h-partners.com> - 2.1.0-15
- fix memory leaks in yajl_tree_parse