diff options
author | Nicolas Williams <nico@cryptonector.com> | 2013-06-17 22:32:54 -0500 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2013-06-18 19:05:52 -0500 |
commit | e4094c8664831862d4eb00e994f8cf9988670e54 (patch) | |
tree | 9281e3fa39d495169cb6ada88ff1e930c61d850e | |
parent | 824ce76cecd11863f6c86cf04e3a56075cbcd30a (diff) |
Fix leaks in jv_load_file()
-rw-r--r-- | jv_file.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -28,12 +28,15 @@ jv jv_load_file(const char* filename, int raw) { if (raw) { data = jv_string_concat(data, jv_string_sized(buf, (int)n)); } else { - jv_parser_set_buf(&parser, buf, strlen(buf), !feof(file)); + jv_parser_set_buf(&parser, buf, n, !feof(file)); jv value; while (jv_is_valid((value = jv_parser_next(&parser)))) data = jv_array_append(data, value); + jv_free(value); } } + if (!raw) + jv_parser_free(&parser); int badread = ferror(file); fclose(file); if (badread) { |