aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parser.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/parser.c b/src/parser.c
index e622b5f..c136a36 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1035,12 +1035,17 @@ int parser_parse_buffer(Parser *self, BufferView code_buffer, BufferView buffer_
}
int parser_parse_file(Parser *self, BufferView filepath) {
+ int result;
Buffer file_content;
return_if_error(buffer_init(&file_content, self->allocator));
assert(!self->started && "Parser can't be reused. Create a new parser.");
self->started = bool_true;
assert(filepath.size > 0 && filepath.data[filepath.size] == '\0');
- return_if_error(read_whole_file(filepath.data, &file_content));
+ result = read_whole_file(filepath.data, &file_content);
+ if(result != 0) {
+ buffer_deinit(&file_content);
+ return result;
+ }
return parser_parse_buffer(self, create_buffer_view(file_content.data, file_content.size), filepath);
}