From 86ca1581f70867098f7325a1e15405946475f4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 10 Feb 2018 19:53:49 +0100 Subject: [PATCH 1/2] Fix mismatched deallocators in S4Importer.cpp --- src/openrct2/rct1/S4Importer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index c1eb978cac..8620058350 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -168,8 +168,9 @@ public: const utf8 * path = String::Empty) override { size_t dataSize = stream->GetLength() - stream->GetPosition(); - std::unique_ptr data = std::unique_ptr(stream->ReadArray(dataSize)); - std::unique_ptr decodedData = std::unique_ptr(Memory::Allocate(sizeof(rct1_s4))); + auto deleter_lambda = [dataSize](uint8 * ptr) { Memory::FreeArray(ptr, dataSize); }; + auto data = std::unique_ptr(stream->ReadArray(dataSize), deleter_lambda); + auto decodedData = std::unique_ptr(Memory::Allocate(sizeof(rct1_s4)), Memory::Free); size_t decodedSize; sint32 fileType = sawyercoding_detect_file_type(data.get(), dataSize); From 30cbd0128f1b3dd89615aee5c18cb16fbf0fbc37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 10 Feb 2018 19:59:16 +0100 Subject: [PATCH 2/2] Fix mismatched deallocator in FileClassifier.cpp --- src/openrct2/FileClassifier.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/openrct2/FileClassifier.cpp b/src/openrct2/FileClassifier.cpp index c5ef5e5496..c4c36de660 100644 --- a/src/openrct2/FileClassifier.cpp +++ b/src/openrct2/FileClassifier.cpp @@ -103,7 +103,8 @@ static bool TryClassifyAsS4(IStream * stream, ClassifiedFileInfo * result) try { size_t dataLength = (size_t)stream->GetLength(); - std::unique_ptr data(stream->ReadArray(dataLength)); + auto deleter_lambda = [dataLength](uint8 * ptr) { Memory::FreeArray(ptr, dataLength); }; + std::unique_ptr data(stream->ReadArray(dataLength), deleter_lambda); stream->SetPosition(originalPosition); sint32 fileTypeVersion = sawyercoding_detect_file_type(data.get(), dataLength);