diff --git a/src/emulator.cpp b/src/emulator.cpp index b16b2f7f0..a74c279ba 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -58,6 +58,9 @@ Emulator::Emulator() { } Emulator::~Emulator() { + if (m_corePath) { + free(m_corePath); + } if (m_romLoaded) { unloadRom(); } @@ -360,7 +363,10 @@ bool Emulator::cbEnvironment(unsigned cmd, void* data) { return false; } case RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY: - *reinterpret_cast(data) = corePath().c_str(); + if (!s_loadedEmulator->m_corePath) { + s_loadedEmulator->m_corePath = strdup(corePath().c_str()); + } + *reinterpret_cast(data) = s_loadedEmulator->m_corePath; return true; case RETRO_ENVIRONMENT_GET_CAN_DUPE: *reinterpret_cast(data) = true; diff --git a/src/emulator.h b/src/emulator.h index ce5dc3259..971a32200 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -83,6 +83,8 @@ class Emulator { retro_system_av_info m_avInfo = {}; std::vector m_map; + char* m_corePath = nullptr; + #ifdef _WIN32 HMODULE m_coreHandle = nullptr; #else