From b9fd36debdc4c8340fd3ac144663d824074be790 Mon Sep 17 00:00:00 2001 From: klemek Date: Sat, 16 May 2026 15:52:39 +0200 Subject: [PATCH] fix: project files free --- src/file.c | 2 +- src/project.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/file.c b/src/file.c index c68c5fc..165bc9f 100644 --- a/src/file.c +++ b/src/file.c @@ -131,7 +131,7 @@ void file_write(const char *path, const StringArray *lines) { } void file_free(File *file) { - if (!file->error) { + if (!file->error && file->content != NULL) { free(file->content); } } diff --git a/src/project.c b/src/project.c index 91961b1..4eda19a 100644 --- a/src/project.c +++ b/src/project.c @@ -104,6 +104,12 @@ void project_init(Project *project, const char *project_path, project->sub_counts.length = project->frag_count; + for (unsigned int i = 0; i < project->frag_count; i++) { + for (unsigned int j = 0; j < MAX_SUB_FILE + 1; j++) { + project->fragment_shaders[i][j].content = NULL; + } + } + for (unsigned int i = 0; i < project->frag_count; i++) { project->sub_counts.values[i] = 0; if (!read_fragment_shader_file(project, frag_prefix, i)) { @@ -138,7 +144,9 @@ void project_reload(Project *project, void (*reload_callback)(unsigned int)) { void project_free(Project *project) { for (unsigned int i = 0; i < project->frag_count; i++) { - file_free(&project->fragment_shaders[i][0]); + for (unsigned int j = 0; j < MAX_SUB_FILE + 1; j++) { + file_free(&project->fragment_shaders[i][j]); + } } config_file_free(&project->config);