mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Fix incorrect "sliced" INCBIN causing memory leaks
Oh, how I miss RAII...
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user