GB: Properly unmap ROM base when unloading ROM

This commit is contained in:
Vicki Pfau 2021-03-22 23:48:19 -07:00
parent 2fc5e2d08d
commit c2de079a9d
1 changed files with 4 additions and 0 deletions

View File

@ -293,6 +293,10 @@ void GBSavedataUnmask(struct GB* gb) {
void GBUnloadROM(struct GB* gb) {
// TODO: Share with GBAUnloadROM
off_t romBase = gb->memory.romBase - gb->memory.rom;
if (romBase >= 0 && ((size_t) romBase < gb->memory.romSize || (size_t) romBase < gb->yankedRomSize)) {
gb->memory.romBase = NULL;
}
if (gb->memory.rom && !gb->isPristine) {
if (gb->yankedRomSize) {
gb->yankedRomSize = 0;