Fix memory leak

This commit is contained in:
Lior Halphon 2021-04-02 19:07:28 +03:00
parent 328e2d9e40
commit 39c71b40e7

View File

@ -125,6 +125,11 @@ void GB_configure_cart(GB_gameboy_t *gb)
else if (gb->rom[0x147] != 0 && memcmp(gb->cartridge_type, &GB_cart_defs[0], sizeof(GB_cart_defs[0])) == 0) { else if (gb->rom[0x147] != 0 && memcmp(gb->cartridge_type, &GB_cart_defs[0], sizeof(GB_cart_defs[0])) == 0) {
GB_log(gb, "Cartridge type %02x is not yet supported.\n", gb->rom[0x147]); 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->has_ram) {
if (gb->cartridge_type->mbc_type == GB_MBC2) { if (gb->cartridge_type->mbc_type == GB_MBC2) {