mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix memory leak when loading title sequence.
The buffer for loading the title sequence script was allocated but not free'd
This commit is contained in:
parent
a64e08f997
commit
bed408ef3f
|
@ -54,7 +54,7 @@ extern "C"
|
|||
TitleSequence * LoadTitleSequence(const utf8 * path)
|
||||
{
|
||||
size_t scriptLength;
|
||||
char * script;
|
||||
utf8 * script;
|
||||
std::vector<utf8 *> 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<TitleCommand> commands = LegacyScriptRead(script, scriptLength, saves);
|
||||
Memory::Free(script);
|
||||
|
||||
TitleSequence * seq = CreateTitleSequence();
|
||||
seq->Name = Path::GetFileNameWithoutExtension(path);
|
||||
|
|
Loading…
Reference in New Issue