From 39c71b40e7e6afe07df77fe21a4fc63281e861d9 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 2 Apr 2021 19:07:28 +0300 Subject: [PATCH] Fix memory leak --- Core/mbc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Core/mbc.c b/Core/mbc.c index 1e91ce2..1236a0d 100644 --- a/Core/mbc.c +++ b/Core/mbc.c @@ -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) { 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) {