mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 14:19:55 -06:00
backport Nadia's zstd fix
This commit is contained in:
@ -1214,8 +1214,8 @@ u32 EmuInstance::decompressROM(const u8* inContent, const u32 inSize, unique_ptr
|
|||||||
|
|
||||||
if (realSize != ZSTD_CONTENTSIZE_UNKNOWN)
|
if (realSize != ZSTD_CONTENTSIZE_UNKNOWN)
|
||||||
{
|
{
|
||||||
outContent = make_unique<u8[]>(realSize);
|
auto newOutContent = make_unique<u8[]>(realSize);
|
||||||
u64 decompressed = ZSTD_decompress(outContent.get(), realSize, inContent, inSize);
|
u64 decompressed = ZSTD_decompress(newOutContent.get(), realSize, inContent, inSize);
|
||||||
|
|
||||||
if (ZSTD_isError(decompressed))
|
if (ZSTD_isError(decompressed))
|
||||||
{
|
{
|
||||||
@ -1223,6 +1223,7 @@ u32 EmuInstance::decompressROM(const u8* inContent, const u32 inSize, unique_ptr
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
outContent = std::move(newOutContent);
|
||||||
return realSize;
|
return realSize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1277,7 +1278,6 @@ u32 EmuInstance::decompressROM(const u8* inContent, const u32 inSize, unique_ptr
|
|||||||
}
|
}
|
||||||
} while (inBuf.pos < inBuf.size);
|
} while (inBuf.pos < inBuf.size);
|
||||||
|
|
||||||
ZSTD_freeDStream(dStream);
|
|
||||||
outContent = make_unique<u8[]>(outBuf.pos);
|
outContent = make_unique<u8[]>(outBuf.pos);
|
||||||
memcpy(outContent.get(), outBuf.dst, outBuf.pos);
|
memcpy(outContent.get(), outBuf.dst, outBuf.pos);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user