diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-07-06 12:09:44 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-07-06 12:09:44 -0300 |
commit | b57574d6fb9071b2f8f261b32c9378ed72db7023 (patch) | |
tree | 41c6503788b696b6056c2d954da84843eebe321e /lcorolib.c | |
parent | bfcf06d91a87b7ffb8c83e290db0cb6176a167f8 (diff) | |
download | lua-b57574d6fb9071b2f8f261b32c9378ed72db7023.tar.gz lua-b57574d6fb9071b2f8f261b32c9378ed72db7023.tar.bz2 lua-b57574d6fb9071b2f8f261b32c9378ed72db7023.zip |
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.
Diffstat (limited to 'lcorolib.c')
-rw-r--r-- | lcorolib.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -73,11 +73,12 @@ static int luaB_coresume (lua_State *L) { | |||
73 | static int luaB_auxwrap (lua_State *L) { | 73 | static int luaB_auxwrap (lua_State *L) { |
74 | lua_State *co = lua_tothread(L, lua_upvalueindex(1)); | 74 | lua_State *co = lua_tothread(L, lua_upvalueindex(1)); |
75 | int r = auxresume(L, co, lua_gettop(L)); | 75 | int r = auxresume(L, co, lua_gettop(L)); |
76 | if (r < 0) { | 76 | if (r < 0) { /* error? */ |
77 | int stat = lua_status(co); | 77 | int stat = lua_status(co); |
78 | if (stat != LUA_OK && stat != LUA_YIELD) | 78 | if (stat != LUA_OK && stat != LUA_YIELD) /* error in the coroutine? */ |
79 | lua_resetthread(co); /* close variables in case of errors */ | 79 | lua_resetthread(co); /* close its tbc variables */ |
80 | if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */ | 80 | if (stat != LUA_ERRMEM && /* not a memory error and ... */ |
81 | lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */ | ||
81 | luaL_where(L, 1); /* add extra info, if available */ | 82 | luaL_where(L, 1); /* add extra info, if available */ |
82 | lua_insert(L, -2); | 83 | lua_insert(L, -2); |
83 | lua_concat(L, 2); | 84 | lua_concat(L, 2); |