From c1b8230eeff5f67db3c5452fe0369c74f7dcee4c Mon Sep 17 00:00:00 2001 From: Tomas Dittmann Date: Thu, 13 Jul 2017 19:56:33 +0200 Subject: [PATCH] Wrap the FileStream creation in try-catch. (#5840) --- src/openrct2/title/TitleSequence.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/openrct2/title/TitleSequence.cpp b/src/openrct2/title/TitleSequence.cpp index 191ca573a5..64b6bf9936 100644 --- a/src/openrct2/title/TitleSequence.cpp +++ b/src/openrct2/title/TitleSequence.cpp @@ -154,9 +154,22 @@ extern "C" String::Set(absolutePath, sizeof(absolutePath), seq->Path); Path::Append(absolutePath, sizeof(absolutePath), filename); - handle = Memory::Allocate(); - handle->Stream = new FileStream(absolutePath, FILE_MODE_OPEN); - handle->HintPath = String::Duplicate(filename); + FileStream* fileStream = nullptr; + try + { + fileStream = new FileStream(absolutePath, FILE_MODE_OPEN); + } + catch (const IOException& exception) + { + Console::Error::WriteLine(exception.GetMessage()); + } + + if (fileStream != nullptr) + { + handle = Memory::Allocate(); + handle->Stream = fileStream; + handle->HintPath = String::Duplicate(filename); + } } } return handle;