From 592843e4f4d4e08f24450013e3aec6ae53a5489f Mon Sep 17 00:00:00 2001 From: squall-leonhart Date: Sat, 29 Aug 2009 21:04:19 +0000 Subject: [PATCH] Applied Chrono's UPS Fix patch --- src/common/Patch.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/common/Patch.cpp b/src/common/Patch.cpp index d908e89b..07daabfb 100644 --- a/src/common/Patch.cpp +++ b/src/common/Patch.cpp @@ -232,16 +232,25 @@ static bool patchApplyUPS(const char *patchname, u8 **rom, int *size) s64 dstSize = readVarPtr(f); if (crc == srcCRC) { - dataSize = srcSize; - } else if (crc == dstCRC) { + if (srcSize != *size) { + fclose(f); + return false; + } dataSize = dstSize; + } else if (crc == dstCRC) { + if (dstSize != *size) { + fclose(f); + return false; + } + dataSize = srcSize; } else { fclose(f); return false; } - if (dataSize != *size) { - fclose(f); - return false; + if (dataSize > *size) { + *rom = (u8*)realloc(*rom, dataSize); + memset(*rom + *size, 0, dataSize - *size); + *size = dataSize; } s64 relative = 0;