diff --git a/nse_main.cc b/nse_main.cc index 79bb1f92a..3c64b4e14 100644 --- a/nse_main.cc +++ b/nse_main.cc @@ -591,6 +591,13 @@ void open_nse (void) { if (L_NSE == NULL) { + /* + Set the random seed value on behalf of scripts. Since Lua uses the + C rand and srand functions, which have a static seed for the entire + program, we don't want scripts doing this themselves. + */ + srand(get_random_uint()); + if ((L_NSE = luaL_newstate()) == NULL) fatal("%s: failed to open a Lua state!", SCRIPT_ENGINE); lua_atpanic(L_NSE, panic); @@ -615,13 +622,6 @@ void script_scan (std::vector &targets, stype scantype) assert(L_NSE != NULL); lua_settop(L_NSE, 0); /* clear the stack */ - /* - Set the random seed value on behalf of scripts. Since Lua uses the C rand - and srand functions, which have a static seed for the entire program, we - don't want scripts doing this themselves. - */ - srand(get_random_uint()); - #if 0 /* Lua 5.2 */ lua_pushcfunction(L_NSE, run_main);