From: Eric Haszlakiewicz Date: Sun, 24 Jul 2022 18:59:26 +0000 (+0000) Subject: Add test to check for the memory leak mentioned in issue #781 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16208fc01afcd742fd5e6736f52849ad2ec03e8f;p=json-c Add test to check for the memory leak mentioned in issue #781 --- diff --git a/tests/test_set_value.c b/tests/test_set_value.c index f51a2a5..a8ebbfe 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");