Browse code

Try to avoid audio callback from working after free

Bad Diode authored on 17/10/2023 18:16:47 • neauoire committed on 03/11/2023 00:30:14
Showing 1 changed files
... ...
@@ -509,7 +509,7 @@ emu_run(Uxn *u, char *rom)
509 509
 static int
510 510
 emu_end(Uxn *u)
511 511
 {
512
-	free(u->ram);
512
+    SDL_CloseAudioDevice(audio_id);
513 513
 #ifdef _WIN32
514 514
 #pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
515 515
 	TerminateThread((HANDLE)SDL_GetThreadID(stdin_thread), 0);
... ...
@@ -517,6 +517,7 @@ emu_end(Uxn *u)
517 517
 	close(0); /* make stdin thread exit */
518 518
 #endif
519 519
 	SDL_Quit();
520
+	free(u->ram);
520 521
 	return u->dev[0x0f] & 0x7f;
521 522
 }
522 523