From 91ec40d5b191e8075848aa88d9372df9d2a9ec27 Mon Sep 17 00:00:00 2001 From: anth64 Date: Wed, 28 Jan 2026 00:18:29 +0100 Subject: [PATCH] fix: nullify module slots after unload * Set all module slot fields (handle, init, shutdown, id) to NULL/empty after unloading to prevent use-after-free and enable proper hole detection during array defragmentation. --- src/module.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/module.c b/src/module.c index afb0f70..0fd729d 100644 --- a/src/module.c +++ b/src/module.c @@ -149,6 +149,10 @@ void stk_module_unload(size_t index) { stk_shutdowns[index](); platform_unload_library(stk_handles[index]); + stk_handles[index] = NULL; + stk_inits[index] = NULL; + stk_shutdowns[index] = NULL; + stk_module_ids[index][0] = '\0'; } void stk_module_free_memory(void)