summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2013-06-17 22:32:54 -0500
committerNicolas Williams <nico@cryptonector.com>2013-06-18 19:05:52 -0500
commite4094c8664831862d4eb00e994f8cf9988670e54 (patch)
tree9281e3fa39d495169cb6ada88ff1e930c61d850e
parent824ce76cecd11863f6c86cf04e3a56075cbcd30a (diff)
Fix leaks in jv_load_file()
-rw-r--r--jv_file.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/jv_file.c b/jv_file.c
index 980a2454..7532a025 100644
--- a/jv_file.c
+++ b/jv_file.c
@@ -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) {