Add test to check for the memory leak mentioned in issue #781

This commit is contained in:
Eric Haszlakiewicz
2022-07-24 18:59:26 +00:00
parent 2a2d861bc0
commit 16208fc01a

View File

@@ -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");