From a2ee0c20dcaf90e4fbb0443db94568db5cd48d7b Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 24 Oct 2014 02:23:37 -0700 Subject: [PATCH] Fix filename getting deleted early --- src/platform/qt/GameController.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 71744089c..11fc1dd98 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -140,7 +140,7 @@ void GameController::openGame() { m_threadContext.sync.videoFrameWait = m_videoSync; m_threadContext.sync.audioWait = m_audioSync; - m_threadContext.fname = m_fname.toLocal8Bit().constData(); + m_threadContext.fname = strdup(m_fname.toLocal8Bit().constData()); if (m_dirmode) { m_threadContext.gameDir = VDirOpen(m_threadContext.fname); m_threadContext.stateDir = m_threadContext.gameDir; @@ -186,6 +186,10 @@ void GameController::closeGame() { } GBAThreadEnd(&m_threadContext); GBAThreadJoin(&m_threadContext); + if (m_threadContext.fname) { + free(const_cast(m_threadContext.fname)); + m_threadContext.fname = nullptr; + } m_gameOpen = false; emit gameStopped(&m_threadContext);