diff --git a/src/lgc.c b/src/lgc.c
index 7c29fb0..df26798 100644
--- a/src/lgc.c
+++ b/src/lgc.c
@@ -942,6 +942,8 @@ static void setpause (global_State *g) {
? estimate * g->gcpause /* no overflow */
: MAX_LMEM; /* overflow; truncate to maximum */
debt = gettotalbytes(g) - threshold;
+ if (debt > 0)
+ debt = 0;
luaE_setdebt(g, debt);
}
A large positive debt number would stop the world, I think we should avoid it.