From bed408ef3f9511ae96abeb0d7411c62995f2f6e3 Mon Sep 17 00:00:00 2001 From: ceeac Date: Fri, 26 May 2017 09:39:08 +0200 Subject: [PATCH] Fix memory leak when loading title sequence. The buffer for loading the title sequence script was allocated but not free'd --- src/openrct2/title/TitleSequence.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/openrct2/title/TitleSequence.cpp b/src/openrct2/title/TitleSequence.cpp index 786235e98b..887b0dff8c 100644 --- a/src/openrct2/title/TitleSequence.cpp +++ b/src/openrct2/title/TitleSequence.cpp @@ -54,7 +54,7 @@ extern "C" TitleSequence * LoadTitleSequence(const utf8 * path) { size_t scriptLength; - char * script; + utf8 * script; std::vector saves; bool isZip; @@ -70,7 +70,7 @@ extern "C" return nullptr; } - script = (char *)zip->GetFileData("script.txt", &scriptLength); + script = (utf8 *)zip->GetFileData("script.txt", &scriptLength); if (script == nullptr) { Console::Error::WriteLine("Unable to open script.txt in '%s'", path); @@ -88,7 +88,7 @@ extern "C" utf8 scriptPath[MAX_PATH]; String::Set(scriptPath, sizeof(scriptPath), path); Path::Append(scriptPath, sizeof(scriptPath), "script.txt"); - script = (char *)ReadScriptFile(scriptPath, &scriptLength); + script = (utf8 *)ReadScriptFile(scriptPath, &scriptLength); if (script == nullptr) { Console::Error::WriteLine("Unable to open '%s'", scriptPath); @@ -100,6 +100,7 @@ extern "C" } std::vector commands = LegacyScriptRead(script, scriptLength, saves); + Memory::Free(script); TitleSequence * seq = CreateTitleSequence(); seq->Name = Path::GetFileNameWithoutExtension(path);