mirror of
https://github.com/json-c/json-c.git
synced 2026-04-04 12:59:07 +08:00
Add test to check for the memory leak mentioned in issue #781
This commit is contained in:
@@ -71,6 +71,14 @@ int main(int argc, char **argv)
|
|||||||
json_object_set_string(tmp, SHORT);
|
json_object_set_string(tmp, SHORT);
|
||||||
assert(strcmp(json_object_get_string(tmp), SHORT) == 0);
|
assert(strcmp(json_object_get_string(tmp), SHORT) == 0);
|
||||||
assert(strcmp(json_object_to_json_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);
|
json_object_put(tmp);
|
||||||
printf("STRING PASSED\n");
|
printf("STRING PASSED\n");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user