]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Prevent GC estimate miscalculation due to buffer growth.
authorMike Pall <mike>
Tue, 22 Apr 2014 09:26:52 +0000 (11:26 +0200)
committerMike Pall <mike>
Tue, 22 Apr 2014 09:26:52 +0000 (11:26 +0200)
src/lj_gc.c

index c2bc397d4bd37525377b6fcbde262bd2bb476d40..c856df4db6beb9c1f27f77e29a222b862cb4d09f 100644 (file)
@@ -631,6 +631,8 @@ static size_t gc_onestep(lua_State *L)
   case GCSsweep: {
     MSize old = g->gc.total;
     setmref(g->gc.sweep, gc_sweep(g, mref(g->gc.sweep, GCRef), GCSWEEPMAX));
+    lua_assert(old >= g->gc.total);
+    g->gc.estimate -= old - g->gc.total;
     if (gcref(*mref(g->gc.sweep, GCRef)) == NULL) {
       gc_shrink(g, L);
       if (gcref(g->gc.mmudata)) {  /* Need any finalizations? */
@@ -643,8 +645,6 @@ static size_t gc_onestep(lua_State *L)
        g->gc.debt = 0;
       }
     }
-    lua_assert(old >= g->gc.total);
-    g->gc.estimate -= old - g->gc.total;
     return GCSWEEPMAX*GCSWEEPCOST;
     }
   case GCSfinalize: