1 Star 0 Fork 31

chenhaixing/json-c

forked from src-openEuler/json-c 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Add-test-to-check-for-the-memory-leak-mentioned-in-issue-781.patch 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
klmengkd 提交于 2022-11-14 19:30 +08:00 . add backport patch
From 16208fc01afcd742fd5e6736f52849ad2ec03e8f Mon Sep 17 00:00:00 2001
From: Eric Haszlakiewicz <erh+git@nimenees.com>
Date: Sun, 24 Jul 2022 18:59:26 +0000
Subject: [PATCH] Add test to check for the memory leak mentioned in issue #781
Conflict:NA
Reference:https://github.com/json-c/json-c/commit/16208fc01afcd742fd5e6736f52849ad2ec03e8f
---
tests/test_set_value.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tests/test_set_value.c b/tests/test_set_value.c
index f51a2a5b67..a8ebbfec79 100644
--- a/tests/test_set_value.c
+++ b/tests/test_set_value.c
@@ -71,6 +71,14 @@ int main(int argc, char **argv)
json_object_set_string(tmp, SHORT);
assert(strcmp(json_object_get_string(tmp), SHORT) == 0);
assert(strcmp(json_object_to_json_string(tmp), "\"" SHORT "\"") == 0);
+
+ // Set an empty string a couple times to try to trigger
+ // a case that used to leak memory.
+ json_object_set_string(tmp, "");
+ json_object_set_string(tmp, HUGE);
+ json_object_set_string(tmp, "");
+ json_object_set_string(tmp, HUGE);
+
json_object_put(tmp);
printf("STRING PASSED\n");
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chen-haixing-hw/json-c.git
git@gitee.com:chen-haixing-hw/json-c.git
chen-haixing-hw
json-c
json-c
master

搜索帮助