From 8375194847f4bcaf17e58b1b74efb7aebb0caf19 Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 9 Oct 2026 14:41:46 +0000 Subject: [PATCH] Preload NSE libs but do not 'require' them until used --- nse_main.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nse_main.cc b/nse_main.cc index 210886a00..9a9b721f7 100644 --- a/nse_main.cc +++ b/nse_main.cc @@ -659,10 +659,12 @@ static void set_nmap_libraries (lua_State *L) {NULL, NULL} }; + luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); for (int i = 0; libs[i].name; i++) { - luaL_requiref(L, libs[i].name, libs[i].func, 1); - lua_pop(L, 1); + lua_pushcfunction(L, libs[i].func); + lua_setfield(L, -2, libs[i].name); } + lua_pop(L, 1); // remove PRELOAD table } static int init_main (lua_State *L)