mirror of https://github.com/mgba-emu/mgba.git
GBA Context: Fix crash when destroying a GBAContext that has BIOS loaded
This commit is contained in:
parent
5f912d231f
commit
f5d6d6fbc9
|
@ -72,6 +72,10 @@ bool GBAContextInit(struct GBAContext* context, const char* port) {
|
||||||
void GBAContextDeinit(struct GBAContext* context) {
|
void GBAContextDeinit(struct GBAContext* context) {
|
||||||
ARMDeinit(context->cpu);
|
ARMDeinit(context->cpu);
|
||||||
GBADestroy(context->gba);
|
GBADestroy(context->gba);
|
||||||
|
if (context->bios) {
|
||||||
|
context->bios->close(context->bios);
|
||||||
|
context->bios = 0;
|
||||||
|
}
|
||||||
mappedMemoryFree(context->gba, 0);
|
mappedMemoryFree(context->gba, 0);
|
||||||
mappedMemoryFree(context->cpu, 0);
|
mappedMemoryFree(context->cpu, 0);
|
||||||
GBAConfigDeinit(&context->config);
|
GBAConfigDeinit(&context->config);
|
||||||
|
@ -103,10 +107,6 @@ bool GBAContextLoadROM(struct GBAContext* context, const char* path, bool autolo
|
||||||
void GBAContextUnloadROM(struct GBAContext* context) {
|
void GBAContextUnloadROM(struct GBAContext* context) {
|
||||||
GBAUnloadROM(context->gba);
|
GBAUnloadROM(context->gba);
|
||||||
GBADirectorySetDetachBase(&context->dirs);
|
GBADirectorySetDetachBase(&context->dirs);
|
||||||
if (context->bios) {
|
|
||||||
context->bios->close(context->bios);
|
|
||||||
context->bios = 0;
|
|
||||||
}
|
|
||||||
if (context->rom) {
|
if (context->rom) {
|
||||||
context->rom->close(context->rom);
|
context->rom->close(context->rom);
|
||||||
context->rom = 0;
|
context->rom = 0;
|
||||||
|
|
Loading…
Reference in New Issue