Skip to content

Commit

Permalink
Merge pull request #18244 from unknownbrackets/fileloader-leak
Browse files Browse the repository at this point in the history
Core: Stop leaking file loaders
  • Loading branch information
hrydgard committed Sep 26, 2023
2 parents 01035f4 + b0dd2a5 commit cc61654
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Core/System.cpp
Expand Up @@ -91,7 +91,7 @@ MetaFileSystem pspFileSystem;
ParamSFOData g_paramSFO;
static GlobalUIState globalUIState;
CoreParameter g_CoreParameter;
static FileLoader *loadedFile;
static FileLoader *g_loadedFile;
// For background loading thread.
static std::mutex loadingLock;
// For loadingReason updates.
Expand Down Expand Up @@ -324,6 +324,7 @@ bool CPU_Init(std::string *errorString, FileLoader *loadedFile) {

// If they shut down early, we'll catch it when load completes.
// Note: this may return before init is complete, which is checked if CPU_IsReady().
g_loadedFile = loadedFile;
if (!LoadFile(&loadedFile, &g_CoreParameter.errorString)) {
CPU_Shutdown();
g_CoreParameter.fileToStart.clear();
Expand Down Expand Up @@ -368,8 +369,8 @@ void CPU_Shutdown() {
Memory::Shutdown();
HLEPlugins::Shutdown();

delete loadedFile;
loadedFile = nullptr;
delete g_loadedFile;
g_loadedFile = nullptr;

delete g_CoreParameter.mountIsoLoader;
delete g_symbolMap;
Expand All @@ -380,8 +381,8 @@ void CPU_Shutdown() {

// TODO: Maybe loadedFile doesn't even belong here...
void UpdateLoadedFile(FileLoader *fileLoader) {
delete loadedFile;
loadedFile = fileLoader;
delete g_loadedFile;
g_loadedFile = fileLoader;
}

void Core_UpdateState(CoreState newState) {
Expand Down

0 comments on commit cc61654

Please sign in to comment.