From 9b9aad8bee56c918d12c28a5515d111abe6804ad Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 12 Jan 2024 11:07:16 +0100 Subject: [PATCH] RTech: fix bug in pakfile decompress callback * Fix decompress size check. * Fix incorrect decompress buffer allocation size. --- r5dev/common/callback.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r5dev/common/callback.cpp b/r5dev/common/callback.cpp index 7b7f1970..ae8d71ce 100644 --- a/r5dev/common/callback.cpp +++ b/r5dev/common/callback.cpp @@ -560,7 +560,7 @@ void RTech_Decompress_f(const CCommand& args) PakDecompState_t decompState; const uint64_t nDecompSize = g_pRTech->DecompressPakFileInit(&decompState, pPakBuf, unsignedPakLen, NULL, sizeof(PakFileHeader_t)); - if (nDecompSize == pHeader->m_compressedSize) + if (nDecompSize != pHeader->m_decompressedSize) { Error(eDLL_T::RTECH, NO_ERROR, "%s - calculated size: '%llu' expected: '%llu'!\n", __FUNCTION__, nDecompSize, pHeader->m_decompressedSize); @@ -575,7 +575,7 @@ void RTech_Decompress_f(const CCommand& args) Msg(eDLL_T::RTECH, " | |-- Ratio : '%.02f'\n", (pHeader->m_compressedSize * 100.f) / pHeader->m_decompressedSize); - std::unique_ptr pDecompBufContainer(new uint8_t[nPakLen]); + std::unique_ptr pDecompBufContainer(new uint8_t[pHeader->m_decompressedSize]); uint8_t* const pDecompBuf = pDecompBufContainer.get(); decompState.m_outputMask = UINT64_MAX;