From d404f0c276e4a81d044be8c7647635acbe13ff06 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 21 Nov 2002 12:14:42 -0200 Subject: global_State must be deallocated (and so allocated) with NULL also (otherwise it trys to decrement inside itself after its own free) --- lstate.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lstate.c') diff --git a/lstate.c b/lstate.c index 323e5562..eb354d80 100644 --- a/lstate.c +++ b/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 1.112 2002/11/18 11:01:55 roberto Exp roberto $ +** $Id: lstate.c,v 1.113 2002/11/19 14:12:13 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -84,8 +84,9 @@ static void freestack (lua_State *L, lua_State *L1) { */ static void f_luaopen (lua_State *L, void *ud) { /* create a new global state */ - global_State *g = luaM_new(L, global_State); + global_State *g = luaM_new(NULL, global_State); UNUSED(ud); + if (g == NULL) luaD_throw(L, LUA_ERRMEM); L->l_G = g; g->mainthread = L; g->GCthreshold = 0; /* mark it as unfinished state */ @@ -147,7 +148,7 @@ static void close_state (lua_State *L) { freestack(L, L); if (G(L)) { lua_assert(G(L)->nblocks == sizeof(lua_State) + sizeof(global_State)); - luaM_freelem(L, G(L)); + luaM_freelem(NULL, G(L)); } freestate(NULL, L); } -- cgit v1.2.3-55-g6feb