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. --- lcorolib.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lcorolib.c') diff --git a/lcorolib.c b/lcorolib.c index 7d6e585b..c165031d 100644 --- a/lcorolib.c +++ b/lcorolib.c @@ -73,11 +73,12 @@ static int luaB_coresume (lua_State *L) { static int luaB_auxwrap (lua_State *L) { lua_State *co = lua_tothread(L, lua_upvalueindex(1)); int r = auxresume(L, co, lua_gettop(L)); - if (r < 0) { + if (r < 0) { /* error? */ int stat = lua_status(co); - if (stat != LUA_OK && stat != LUA_YIELD) - lua_resetthread(co); /* close variables in case of errors */ - if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */ + if (stat != LUA_OK && stat != LUA_YIELD) /* error in the coroutine? */ + lua_resetthread(co); /* close its tbc variables */ + if (stat != LUA_ERRMEM && /* not a memory error and ... */ + lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */ luaL_where(L, 1); /* add extra info, if available */ lua_insert(L, -2); lua_concat(L, 2); -- cgit v1.2.3-55-g6feb