aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-06 12:09:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-06 12:09:44 -0300
commitb57574d6fb9071b2f8f261b32c9378ed72db7023 (patch)
tree41c6503788b696b6056c2d954da84843eebe321e /lapi.c
parentbfcf06d91a87b7ffb8c83e290db0cb6176a167f8 (diff)
downloadlua-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 'lapi.c')
-rw-r--r--lapi.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lapi.c b/lapi.c
index bbba88a3..16eb170d 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1195,9 +1195,15 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
1195 1195
1196 1196
1197LUA_API int lua_error (lua_State *L) { 1197LUA_API int lua_error (lua_State *L) {
1198 TValue *errobj;
1198 lua_lock(L); 1199 lua_lock(L);
1200 errobj = s2v(L->top - 1);
1199 api_checknelems(L, 1); 1201 api_checknelems(L, 1);
1200 luaG_errormsg(L); 1202 /* error object is the memory error message? */
1203 if (ttisshrstring(errobj) && eqshrstr(tsvalue(errobj), G(L)->memerrmsg))
1204 luaM_error(L); /* raise a memory error */
1205 else
1206 luaG_errormsg(L); /* raise a regular error */
1201 /* code unreachable; will unlock when control actually leaves the kernel */ 1207 /* code unreachable; will unlock when control actually leaves the kernel */
1202 return 0; /* to avoid warnings */ 1208 return 0; /* to avoid warnings */
1203} 1209}