]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Fix error message generation for OOM error.
authorMike Pall <mike>
Sun, 28 Feb 2010 21:22:45 +0000 (22:22 +0100)
committerMike Pall <mike>
Sun, 28 Feb 2010 21:22:45 +0000 (22:22 +0100)
src/lj_err.c
src/lj_gc.c

index 0aaf5497bf8b0bf12458aca7fdd43323dd34f97b..7db37f3bdadda1e0c29591b76924f45b46831bf1 100644 (file)
@@ -737,6 +737,7 @@ LJ_NOINLINE void lj_err_mem(lua_State *L)
 {
   if (L->status == LUA_ERRERR+1)  /* Don't touch the stack during lua_open. */
     lj_vm_unwind_c(L->cframe, LUA_ERRMEM);
+  L->top = L->base;
   setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRMEM));
   lj_err_throw(L, LUA_ERRMEM);
 }
index 19cc9e7bb3e4cf7e975bd8a20548e75d7b8db3b2..276cd4dab44b9fa80af2ed1f3dce37f4bd73e22b 100644 (file)
@@ -746,7 +746,7 @@ void *lj_mem_realloc(lua_State *L, void *p, MSize osz, MSize nsz)
   lua_assert((osz == 0) == (p == NULL));
   p = g->allocf(g->allocd, p, osz, nsz);
   if (p == NULL && nsz > 0)
-    lj_err_throw(L, LUA_ERRMEM);
+    lj_err_mem(L);
   lua_assert((nsz == 0) == (p == NULL));
   lua_assert(checkptr32(p));
   g->gc.total = (g->gc.total - osz) + nsz;
@@ -759,7 +759,7 @@ void *lj_mem_newgco(lua_State *L, MSize size)
   global_State *g = G(L);
   GCobj *o = (GCobj *)g->allocf(g->allocd, NULL, 0, size);
   if (o == NULL)
-    lj_err_throw(L, LUA_ERRMEM);
+    lj_err_mem(L);
   lua_assert(checkptr32(o));
   g->gc.total += size;
   setgcrefr(o->gch.nextgc, g->gc.root);