diff options
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.127 2014/11/02 19:33:33 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.128 2015/03/04 13:31:21 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -93,10 +93,14 @@ static unsigned int makeseed (lua_State *L) { | |||
93 | 93 | ||
94 | /* | 94 | /* |
95 | ** set GCdebt to a new value keeping the value (totalbytes + GCdebt) | 95 | ** set GCdebt to a new value keeping the value (totalbytes + GCdebt) |
96 | ** invariant | 96 | ** invariant (and avoiding underflows in 'totalbytes') |
97 | */ | 97 | */ |
98 | void luaE_setdebt (global_State *g, l_mem debt) { | 98 | void luaE_setdebt (global_State *g, l_mem debt) { |
99 | g->totalbytes -= (debt - g->GCdebt); | 99 | l_mem tb = gettotalbytes(g); |
100 | lua_assert(tb > 0); | ||
101 | if (debt < tb - MAX_LMEM) | ||
102 | debt = tb - MAX_LMEM; /* will make 'totalbytes == MAX_LMEM' */ | ||
103 | g->totalbytes = tb - debt; | ||
100 | g->GCdebt = debt; | 104 | g->GCdebt = debt; |
101 | } | 105 | } |
102 | 106 | ||