Browse Source

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

tags/json-c-0.17-20230812
Eric Haszlakiewicz 3 years ago
parent
commit
16208fc01a
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      tests/test_set_value.c

+ 8
- 0
tests/test_set_value.c View File

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




Loading…
Cancel
Save