Read the file into a dynamic array to avoid stack overflow

This commit is contained in:
2023-07-02 20:50:24 +01:00
parent dde80250ed
commit f1519cf0ea
2 changed files with 47 additions and 46 deletions

View File

@@ -33,7 +33,7 @@ jentity_t *load_json(const char *filepath) {
fseek(fp, 0, SEEK_SET);
char json[length + 1];
char *json = (char *)malloc(sizeof(char) * (length + 1));
memset(json, 0, length + 1);
fread(json, sizeof(char), length, fp);
@@ -76,6 +76,7 @@ jentity_t *load_json(const char *filepath) {
parser_free(&parser);
lexer_free(&lexer);
free(json);
return root;
}