32 lines
1.1 KiB
Diff
32 lines
1.1 KiB
Diff
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");
|
|
|