Fix leaks in jv_load_file()

This commit is contained in:
Nicolas Williams committed 2013-06-18 19:05:52 -05:00
1 parent 824ce76cec
commit e4094c8664
1 file changed
+4 -1
+4 -1
View File
@@ -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) {