Fix path name use-after-free

This commit is contained in:
Jeffrey Pfau 2014-10-14 23:15:31 -07:00
parent fdf2ce299c
commit c60a5ea545
1 changed files with 5 additions and 1 deletions

View File

@ -126,7 +126,7 @@ void GameController::loadGame(const QString& path) {
m_pauseAfterFrame = false; m_pauseAfterFrame = false;
m_threadContext.rom = VFileFromFD(m_rom->handle()); m_threadContext.rom = VFileFromFD(m_rom->handle());
m_threadContext.fname = path.toLocal8Bit().constData(); m_threadContext.fname = strdup(path.toLocal8Bit().constData());
GBAThreadStart(&m_threadContext); GBAThreadStart(&m_threadContext);
} }
@ -137,6 +137,10 @@ void GameController::closeGame() {
} }
GBAThreadEnd(&m_threadContext); GBAThreadEnd(&m_threadContext);
GBAThreadJoin(&m_threadContext); GBAThreadJoin(&m_threadContext);
if (m_threadContext.fname) {
free(const_cast<char*>(m_threadContext.fname));
m_threadContext.fname = nullptr;
}
if (m_rom) { if (m_rom) {
m_rom->close(); m_rom->close();
delete m_rom; delete m_rom;