From 1399b5da478134dadc133a0e65a349f724655f22 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Tue, 17 Oct 2023 20:16:47 +0200 Subject: [PATCH] Try to avoid audio callback from working after free --- src/uxnemu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/uxnemu.c b/src/uxnemu.c index 67f4951..a473a4b 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -472,7 +472,7 @@ emu_run(Uxn *u, char *rom) static int emu_end(Uxn *u) { - free(u->ram); + SDL_CloseAudioDevice(audio_id); #ifdef _WIN32 #pragma GCC diagnostic ignored "-Wint-to-pointer-cast" TerminateThread((HANDLE)SDL_GetThreadID(stdin_thread), 0); @@ -480,6 +480,7 @@ emu_end(Uxn *u) close(0); /* make stdin thread exit */ #endif SDL_Quit(); + free(u->ram); return u->dev[0x0f] & 0x7f; }