Merge pull request #7161 from janisozaur/deleters-s4importer

Fix mismatched deallocators in S4Importer.cpp
This commit is contained in:
Ted John 2018-02-10 22:48:54 +00:00 committed by GitHub
commit 4dfed04cef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -103,7 +103,8 @@ static bool TryClassifyAsS4(IStream * stream, ClassifiedFileInfo * result)
try
{
size_t dataLength = (size_t)stream->GetLength();
std::unique_ptr<uint8> data(stream->ReadArray<uint8>(dataLength));
auto deleter_lambda = [dataLength](uint8 * ptr) { Memory::FreeArray(ptr, dataLength); };
std::unique_ptr<uint8, decltype(deleter_lambda)> data(stream->ReadArray<uint8>(dataLength), deleter_lambda);
stream->SetPosition(originalPosition);
sint32 fileTypeVersion = sawyercoding_detect_file_type(data.get(), dataLength);

View File

@ -168,8 +168,9 @@ public:
const utf8 * path = String::Empty) override
{
size_t dataSize = stream->GetLength() - stream->GetPosition();
std::unique_ptr<uint8> data = std::unique_ptr<uint8>(stream->ReadArray<uint8>(dataSize));
std::unique_ptr<uint8> decodedData = std::unique_ptr<uint8>(Memory::Allocate<uint8>(sizeof(rct1_s4)));
auto deleter_lambda = [dataSize](uint8 * ptr) { Memory::FreeArray(ptr, dataSize); };
auto data = std::unique_ptr<uint8, decltype(deleter_lambda)>(stream->ReadArray<uint8>(dataSize), deleter_lambda);
auto decodedData = std::unique_ptr<uint8, void(*)(uint8*)>(Memory::Allocate<uint8>(sizeof(rct1_s4)), Memory::Free);
size_t decodedSize;
sint32 fileType = sawyercoding_detect_file_type(data.get(), dataSize);