aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.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 /lauxlib.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 'lauxlib.c')
-rw-r--r--lauxlib.c6
1 files changed, 4 insertions, 2 deletions
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) {
475 lua_Alloc allocf = lua_getallocf(L, &ud); 475 lua_Alloc allocf = lua_getallocf(L, &ud);
476 UBox *box = (UBox *)lua_touserdata(L, idx); 476 UBox *box = (UBox *)lua_touserdata(L, idx);
477 void *temp = allocf(ud, box->box, box->bsize, newsize); 477 void *temp = allocf(ud, box->box, box->bsize, newsize);
478 if (temp == NULL && newsize > 0) /* allocation error? */ 478 if (temp == NULL && newsize > 0) { /* allocation error? */
479 luaL_error(L, "not enough memory"); 479 lua_pushliteral(L, "not enough memory");
480 lua_error(L); /* raise a memory error */
481 }
480 box->box = temp; 482 box->box = temp;
481 box->bsize = newsize; 483 box->bsize = newsize;
482 return temp; 484 return temp;