Fix incorrect "sliced" INCBIN causing memory leaks

Oh, how I miss RAII...
This commit is contained in:
ISSOtm
2020-11-29 12:42:49 +01:00
parent de76dcb8fb
commit 213d985e17

View File

@@ -663,9 +663,9 @@ void out_BinaryFile(char const *s, int32_t startPos)
if (fstk_FindFile(s, &fullPath, &size)) if (fstk_FindFile(s, &fullPath, &size))
f = fopen(fullPath, "rb"); f = fopen(fullPath, "rb");
free(fullPath);
if (!f) { if (!f) {
free(fullPath);
if (oGeneratedMissingIncludes) { if (oGeneratedMissingIncludes) {
oFailedOnMissingInclude = true; oFailedOnMissingInclude = true;
return; return;
@@ -682,6 +682,7 @@ void out_BinaryFile(char const *s, int32_t startPos)
if (startPos >= fsize) { if (startPos >= fsize) {
error("Specified start position is greater than length of file\n"); error("Specified start position is greater than length of file\n");
fclose(f);
return; return;
} }
@@ -706,7 +707,6 @@ void out_BinaryFile(char const *s, int32_t startPos)
error("Error reading INCBIN file '%s': %s\n", s, strerror(errno)); error("Error reading INCBIN file '%s': %s\n", s, strerror(errno));
fclose(f); fclose(f);
free(fullPath);
} }
void out_BinaryFileSlice(char const *s, int32_t start_pos, int32_t length) void out_BinaryFileSlice(char const *s, int32_t start_pos, int32_t length)