From b57574d6fb9071b2f8f261b32c9378ed72db7023 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 6 Jul 2020 12:09:44 -0300 Subject: Keep memory errors as memory errors Allow memory errors to be raised through the API (throwing the error with the memory error message); error in external allocations raises a memory error; memory errors in coroutines are re-raised as memory errors. --- lauxlib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index e3d9be37..cbe9ed31 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -475,8 +475,10 @@ static void *resizebox (lua_State *L, int idx, size_t newsize) { lua_Alloc allocf = lua_getallocf(L, &ud); UBox *box = (UBox *)lua_touserdata(L, idx); void *temp = allocf(ud, box->box, box->bsize, newsize); - if (temp == NULL && newsize > 0) /* allocation error? */ - luaL_error(L, "not enough memory"); + if (temp == NULL && newsize > 0) { /* allocation error? */ + lua_pushliteral(L, "not enough memory"); + lua_error(L); /* raise a memory error */ + } box->box = temp; box->bsize = newsize; return temp; -- cgit v1.2.3-55-g6feb