# HG changeset patch # User Michael Pavone # Date 1704166051 28800 # Node ID 34b4ff0918915eef58a23847f1c0fc86a6610ce0 # Parent c97609fe8315b1bff744aa8968c2e7f03117e57a Fix crash when loading a subsequent ROM after lock-on diff -r c97609fe8315 -r 34b4ff091891 blastem.c --- a/blastem.c Sat Dec 23 23:03:31 2023 -0800 +++ b/blastem.c Mon Jan 01 19:27:31 2024 -0800 @@ -436,17 +436,34 @@ num_parts -= 2; } current_system->next_rom = alloc_concat_m(num_parts, start); + if (cart.chain) { + parts[0] = cart.chain->dir; + parts[2] = cart.chain->name; + parts[4] = cart.chain->extension; + start = parts[0] ? parts : parts + 2; + num_parts = parts[0] ? 5 : 3; + char *lock_on_path = alloc_concat_m(num_parts, start); + load_media(lock_on_path, cart.chain, NULL); + free(lock_on_path); + } system_request_exit(current_system, 1); } void lockon_media(char *lock_on_path) { - reload_media(); - cart.chain = &lock_on; free(lock_on.dir); free(lock_on.name); free(lock_on.extension); - load_media(lock_on_path, &lock_on, NULL); + if (lock_on_path) { + reload_media(); + cart.chain = &lock_on; + load_media(lock_on_path, &lock_on, NULL); + } else { + lock_on.dir = NULL; + lock_on.name = NULL; + lock_on.extension = NULL; + cart.chain = NULL; + } } static uint32_t opts = 0; diff -r c97609fe8315 -r 34b4ff091891 nuklear_ui/blastem_nuklear.c --- a/nuklear_ui/blastem_nuklear.c Sat Dec 23 23:03:31 2023 -0800 +++ b/nuklear_ui/blastem_nuklear.c Mon Jan 01 19:27:31 2024 -0800 @@ -109,6 +109,7 @@ static void handle_chooser_result(uint8_t normal_open, char *full_path) { if(normal_open) { + lockon_media(NULL); if (current_system) { current_system->next_rom = full_path; current_system->request_exit(current_system);