lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

Adam D. Moss wrote:
> Is this fix also relevant to vanilla 5.1w4?

Yes. Patch below.

Minimum test case, derived from Mark Hamburg's example:

  function v(f, ...) print("test", f() ~= 1 and "FAILED" or "OK") end
  local x = 1
  return v(function() return x end)

My RVM patch has been updated, too. New patch+patched distro has been
uploaded to the Wiki.

Bye,
     Mike

--- lua-5.1-work4/src/lvm.c.orig	2004-12-03 21:35:33.000000000 +0100
+++ lua-5.1-work4/src/lvm.c	2005-02-18 01:08:24.729433040 +0100
@@ -617,9 +617,8 @@
           int aux;
           StkId func = ci->func;
           StkId pfunc = (ci+1)->func;  /* previous function index */
-          base = ci->base = ci->func + ((ci+1)->base - pfunc);
-          L->base = base;
-          if (L->openupval) luaF_close(L, base);
+          if (L->openupval) luaF_close(L, ci->base);
+          L->base = ci->base = ci->func + ((ci+1)->base - pfunc);
           for (aux = 0; pfunc+aux < L->top; aux++)  /* move frame down */
             setobjs2s(L, func+aux, pfunc+aux);
           ci->top = L->top = func+aux;  /* correct top */