Util: Fix loading UPS patches that affect the last byte of the file

This commit is contained in:
Vicki Pfau 2021-05-02 22:35:28 -07:00
parent e0db333ea3
commit e25efac5fb
2 changed files with 5 additions and 3 deletions

View File

@ -9,6 +9,7 @@ Other fixes:
- Core: Fix memory leak in opening games from the library - Core: Fix memory leak in opening games from the library
- Qt: Fix infrequent deadlock when using sync to video - Qt: Fix infrequent deadlock when using sync to video
- Qt: Fix applying savetype-only overrides - Qt: Fix applying savetype-only overrides
- Util: Fix loading UPS patches that affect the last byte of the file
Misc: Misc:
- Qt: Rearrange menus some - Qt: Rearrange menus some

View File

@ -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) { if (patch->vf->read(patch->vf, &byte, 1) != 1) {
return false; return false;
} }
if (!byte) {
break;
}
if (offset >= outSize) { if (offset >= outSize) {
return false; return false;
} }
buf[offset] ^= byte; buf[offset] ^= byte;
++offset; ++offset;
if (!byte) {
break;
}
} }
++offset;
alreadyRead = patch->vf->seek(patch->vf, 0, SEEK_CUR); alreadyRead = patch->vf->seek(patch->vf, 0, SEEK_CUR);
} }