Fix jv_load_file() (partial fix #799)
This commit is contained in:
1 parent
89c57f7936
commit
4451c08007
1 file changed
+7
-3
@@ -30,14 +30,18 @@ jv jv_load_file(const char* filename, int raw) {
|
|||||||
jv value;
|
jv value;
|
||||||
while (jv_is_valid((value = jv_parser_next(parser))))
|
while (jv_is_valid((value = jv_parser_next(parser))))
|
||||||
data = jv_array_append(data, value);
|
data = jv_array_append(data, value);
|
||||||
jv_free(value);
|
if (jv_invalid_has_msg(jv_copy(value))) {
|
||||||
|
jv_free(data);
|
||||||
|
data = value;
|
||||||
|
value = jv_invalid();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!raw)
|
if (!raw)
|
||||||
jv_parser_free(parser);
|
jv_parser_free(parser);
|
||||||
int badread = ferror(file);
|
int badread = ferror(file);
|
||||||
fclose(file);
|
if (fclose(file) != 0 || badread) {
|
||||||
if (badread) {
|
|
||||||
jv_free(data);
|
jv_free(data);
|
||||||
return jv_invalid_with_msg(jv_string_fmt("Error reading from %s",
|
return jv_invalid_with_msg(jv_string_fmt("Error reading from %s",
|
||||||
filename));
|
filename));
|
||||||
|
|||||||
Reference in new issue
Block a user