Skip to content

Commit

Permalink
#1494 Fix possible file handle leak when file fails to load
Browse files Browse the repository at this point in the history
  • Loading branch information
peter15914 authored Jan 5, 2025
1 parent 3e970f4 commit c8f6834
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions distr/flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -13002,6 +13002,9 @@ char* flecs_load_from_file(

return content;
error:
if (file) {
fclose(file);
}
ecs_os_free(content);
return NULL;
}
Expand Down
3 changes: 3 additions & 0 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ char* flecs_load_from_file(

return content;
error:
if (file) {
fclose(file);
}
ecs_os_free(content);
return NULL;
}
Expand Down

0 comments on commit c8f6834

Please sign in to comment.