Fix memory leak

This commit is contained in:
Lior Halphon 2021-04-02 19:07:28 +03:00
parent 328e2d9e40
commit 39c71b40e7
1 changed files with 5 additions and 0 deletions

View File

@ -126,6 +126,11 @@ void GB_configure_cart(GB_gameboy_t *gb)
GB_log(gb, "Cartridge type %02x is not yet supported.\n", gb->rom[0x147]);
}
if (gb->mbc_ram) {
free(gb->mbc_ram);
gb->mbc_ram = NULL;
}
if (gb->cartridge_type->has_ram) {
if (gb->cartridge_type->mbc_type == GB_MBC2) {
gb->mbc_ram_size = 0x200;