Skip to content

Commit f483373

Browse files
committed
[GEN][ZH] Fix Win32BIGFileSystem leaking file handlers when returning early on null filenames (#623)
1 parent 0120517 commit f483373

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) {
7777
Int archiveFileSize = 0;
7878
Int numLittleFiles = 0;
7979

80-
ArchiveFile *archiveFile = NEW Win32BIGFile;
81-
8280
DEBUG_LOG(("Win32BIGFileSystem::openArchiveFile - opening BIG file %s\n", filename));
8381

8482
if (fp == NULL) {
@@ -120,6 +118,8 @@ ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) {
120118
fp->seek(0x10, File::START);
121119
// read in each directory listing.
122120
ArchivedFileInfo *fileInfo = NEW ArchivedFileInfo;
121+
// TheSuperHackers @fix Mauller 23/04/2025 Only create the new file instance when it is necassary or we leak file handles!
122+
ArchiveFile *archiveFile = NEW Win32BIGFile;
123123

124124
for (Int i = 0; i < numLittleFiles; ++i) {
125125
Int filesize = 0;

GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) {
9090
Int archiveFileSize = 0;
9191
Int numLittleFiles = 0;
9292

93-
ArchiveFile *archiveFile = NEW Win32BIGFile;
94-
9593
DEBUG_LOG(("Win32BIGFileSystem::openArchiveFile - opening BIG file %s\n", filename));
9694

9795
if (fp == NULL) {
@@ -133,6 +131,8 @@ ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) {
133131
fp->seek(0x10, File::START);
134132
// read in each directory listing.
135133
ArchivedFileInfo *fileInfo = NEW ArchivedFileInfo;
134+
// TheSuperHackers @fix Mauller 23/04/2025 Only create the new file instance when it is necassary or we leak file handles!
135+
ArchiveFile *archiveFile = NEW Win32BIGFile;
136136

137137
for (Int i = 0; i < numLittleFiles; ++i) {
138138
Int filesize = 0;

0 commit comments

Comments
 (0)