Fix vm_exit when called before vm_execute_ain

The can happen when launched in the debugger and then exited before
starting execution.
This commit is contained in:
Nunuhara Cabbage
2023-05-07 15:32:29 -07:00
parent cff6272c18
commit d0a2c5ec40
2 changed files with 7 additions and 2 deletions
+5 -1
View File
@@ -539,16 +539,20 @@ static void link_libraries(void)
}
}
bool libraries_initialized = false;
void init_libraries(void)
{
library_run_all("_PreLink");
link_libraries();
library_run_all("_ModuleInit");
libraries_initialized = true;
}
void exit_libraries(void)
{
library_run_all("_ModuleFini");
if (libraries_initialized)
library_run_all("_ModuleFini");
}
void static_library_replace(struct static_library *lib, const char *name, void *fun)
+2 -1
View File
@@ -2295,7 +2295,8 @@ static void vm_free(void)
exit_unref(call_stack[i].page_slot);
}
// free globals
exit_unref(0);
if (heap_size > 0 && heap[0].ref > 0)
exit_unref(0);
}
static jmp_buf reset_buf;