diff options
author | Eric Haszlakiewicz <erh+git@nimenees.com> | 2022-07-24 18:59:26 +0000 |
---|---|---|
committer | Eric Haszlakiewicz <erh+git@nimenees.com> | 2022-07-24 18:59:26 +0000 |
commit | 16208fc01afcd742fd5e6736f52849ad2ec03e8f (patch) | |
tree | 69676ae059c6244529850c3f8a94c64c8d187acd | |
parent | 2a2d861bc0c77a97529895665c643389645686b5 (diff) | |
download | json-c-16208fc01afcd742fd5e6736f52849ad2ec03e8f.tar.gz |
Add test to check for the memory leak mentioned in issue #781
-rw-r--r-- | tests/test_set_value.c | 8 |
1 files changed, 8 insertions, 0 deletions
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"); |