From 3dd109c6d910528de18d4edaedd9c4599fc4d328 Mon Sep 17 00:00:00 2001 From: laqieer Date: Tue, 15 Mar 2022 21:08:19 +0800 Subject: [PATCH] fix the glitch that cut the end of the file if it's larger than the changed file patch was originally created with --- js/formats/ups.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/formats/ups.js b/js/formats/ups.js index 39eecc4..07a81f1 100644 --- a/js/formats/ups.js +++ b/js/formats/ups.js @@ -57,6 +57,11 @@ UPS.prototype.apply=function(romFile, validate){ throw new Error('error_crc_input'); } + /* fix the glitch that cut the end of the file if it's larger than the changed file patch was originally created with */ + sizeOutput = this.sizeOutput + if(!validate && sizeOutput < this.sizeInput){ + sizeOutput = this.sizeInput + } /* copy original file */ tempFile=new MarcFile(this.sizeOutput); @@ -201,4 +206,4 @@ function createUPSFromFiles(original, modified){ patch.checksumInput=crc32(original); patch.checksumOutput=crc32(modified); return patch -} \ No newline at end of file +}