diff --git a/CHANGES b/CHANGES index 31abe963d..86fae6ac9 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,7 @@ Other fixes: - GBA e-Reader: Fix bitmap short strip scanning - GBA Video: Fix mode 5 frame 1 caching (fixes mgba.io/i/2075) Misc: + - Core: Truncate preloading ROMs that slightly exceed max size (fixes mgba.io/i/2093) - GBA: Default-enable VBA bug compat for Ruby and Emerald ROM hacks - Qt: Add ROM filename and size to bug reporter diff --git a/src/core/core.c b/src/core/core.c index fb706eb02..0f56edc08 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -159,7 +159,13 @@ bool mCorePreloadVFCB(struct mCore* core, struct VFile* vf, void (cb)(size_t, si extern uint32_t* romBuffer; extern size_t romBufferSize; if (size > romBufferSize) { - return false; + if (size - romBufferSize < romBufferSize / 2) { + // Some ROM hacks accidentally overflow the size a bit, but since those are broken + // on hardware anyway we can just silently truncate them without issue. + size = romBufferSize; + } else { + return false; + } } vfm = VFileFromMemory(romBuffer, size); #else