ref: 213d985e1730b06ac88429a167292701259d9b91
parent: de76dcb8fb2716f73e7e375c38119333fa9d24a0
author: ISSOtm <eldredhabert0@gmail.com>
date: Sun Nov 29 07:42:49 EST 2020
Fix incorrect "sliced" INCBIN causing memory leaks Oh, how I miss RAII...
--- a/src/asm/section.c
+++ b/src/asm/section.c
@@ -663,9 +663,9 @@
if (fstk_FindFile(s, &fullPath, &size))
f = fopen(fullPath, "rb");
+ free(fullPath);
if (!f) {
- free(fullPath);
if (oGeneratedMissingIncludes) {
oFailedOnMissingInclude = true;
return;
@@ -682,6 +682,7 @@
if (startPos >= fsize) {
error("Specified start position is greater than length of file\n");
+ fclose(f);
return;
}
@@ -706,7 +707,6 @@
error("Error reading INCBIN file '%s': %s\n", s, strerror(errno));
fclose(f);
- free(fullPath);
}
void out_BinaryFileSlice(char const *s, int32_t start_pos, int32_t length)