Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(wwutil): return the FileClass that File_Exists borrowed

Olcay Seygan917f8c9c16a0
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/Wwutil/miscutil.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/Wwutil/miscutil.cpp
index 2fe4a0306..f2e2a2563 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/Wwutil/miscutil.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/Wwutil/miscutil.cpp
@@ -105,12 +105,12 @@ bool cMiscUtil::File_Exists(LPCSTR filename)
return false;
}
#else
+ // The early "return true" used to skip Return_File, so every successful
+ // existence check leaked the FileClass the factory handed out.
FileClass * file = _TheFileFactory->Get_File( filename );
- if ( file && file->Is_Available() ) {
- return true;
- }
+ bool exists = (file != NULL) && file->Is_Available();
_TheFileFactory->Return_File( file );
- return false;
+ return exists;
#endif
}