From ab7fc5a47e5a3e5b4a51a6245bbbacff1d9d0ee4 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 18 Nov 2013 11:12:51 +0100 Subject: Fix internal error at lane creation when the generator doesn't open any base library Fix issue #77. --- src/tools.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/tools.c b/src/tools.c index 684c776..754605b 100644 --- a/src/tools.c +++ b/src/tools.c @@ -579,13 +579,16 @@ lua_State* luaG_newstate( lua_State* _from, int const _on_state_create, char con (void) luaL_error( _from, "'lua_newstate()' failed; out of memory"); } + // we'll need this everytime we transfer some C function from/to this state + lua_newtable( L); + lua_setfield( L, LUA_REGISTRYINDEX, LOOKUP_REGKEY); + // neither libs (not even 'base') nor special init func: we are done if( libs == NULL && _on_state_create <= 0) { DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "luaG_newstate(NULL)\n" INDENT_END)); return L; } - // from this point, we are not creating a keeper state (because libs == NULL when we init keepers) DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "luaG_newstate()\n" INDENT_END)); DEBUGSPEW_CODE( ++ debugspew_indent_depth); @@ -595,10 +598,6 @@ lua_State* luaG_newstate( lua_State* _from, int const _on_state_create, char con // 'lua.c' stops GC during initialization so perhaps its a good idea. :) lua_gc( L, LUA_GCSTOP, 0); - // we'll need this everytime we transfer some C function from/to this state - lua_newtable( L); - lua_setfield( L, LUA_REGISTRYINDEX, LOOKUP_REGKEY); - // Anything causes 'base' to be taken in // if( libs != NULL) -- cgit v1.2.3-55-g6feb