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.
This commit is contained in:
8
lapi.c
8
lapi.c
@@ -1195,9 +1195,15 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
|
||||
|
||||
|
||||
LUA_API int lua_error (lua_State *L) {
|
||||
TValue *errobj;
|
||||
lua_lock(L);
|
||||
errobj = s2v(L->top - 1);
|
||||
api_checknelems(L, 1);
|
||||
luaG_errormsg(L);
|
||||
/* error object is the memory error message? */
|
||||
if (ttisshrstring(errobj) && eqshrstr(tsvalue(errobj), G(L)->memerrmsg))
|
||||
luaM_error(L); /* raise a memory error */
|
||||
else
|
||||
luaG_errormsg(L); /* raise a regular error */
|
||||
/* code unreachable; will unlock when control actually leaves the kernel */
|
||||
return 0; /* to avoid warnings */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user