diff --git a/CHANGES b/CHANGES index 5a607d669..443544da2 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,7 @@ Other fixes: - Core: Fix memory leak in opening games from the library - Qt: Fix infrequent deadlock when using sync to video - Qt: Fix applying savetype-only overrides + - Util: Fix loading UPS patches that affect the last byte of the file 0.9.1: (2021-04-18) Emulation fixes: diff --git a/src/util/patch-ups.c b/src/util/patch-ups.c index ea1d531eb..6c0334feb 100644 --- a/src/util/patch-ups.c +++ b/src/util/patch-ups.c @@ -87,15 +87,16 @@ bool _UPSApplyPatch(struct Patch* patch, const void* in, size_t inSize, void* ou if (patch->vf->read(patch->vf, &byte, 1) != 1) { return false; } + if (!byte) { + break; + } if (offset >= outSize) { return false; } buf[offset] ^= byte; ++offset; - if (!byte) { - break; - } } + ++offset; alreadyRead = patch->vf->seek(patch->vf, 0, SEEK_CUR); }