akheron / jansson

C library for encoding, decoding and manipulating JSON data
http://www.digip.org/jansson/
Other
3.05k stars 809 forks source link

does json_load_file require to free memory #576

Closed jacobkyhsu closed 3 years ago

jacobkyhsu commented 3 years ago

Hi,

in test_load.c in version 2.13.1, if function call json_loads( ), it will json_decref( ) the pointer which return by json_loads. ex: json = json_loads("true", JSON_DECODE_ANY, &error); .... json_decref(json);

But, if function call json_load_file( ), there is no any free memory for return point of json_load_file. if return pointer of json_load_file is valid, do we need to free memory by json_decref() ??

akheron commented 3 years ago

Yes, you need to call json_decref() on the return value of json_load_file() too