Source-Changes-HG archive

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

[src/trunk]: src/external/mit/lua/dist/src fixed metatable access to dealloca...



details:   https://anonhg.NetBSD.org/src/rev/4e2111331cd4
branches:  trunk
changeset: 343295:4e2111331cd4
user:      lneto <lneto%NetBSD.org@localhost>
date:      Thu Jan 28 17:23:21 2016 +0000

description:
fixed metatable access to deallocated field

author: Lua.org <team%lua.org@localhost>
see: http://www.lua.org/bugs.html#5.3.2-1

diffstat:

 external/mit/lua/dist/src/lvm.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (34 lines):

diff -r b31932378529 -r 4e2111331cd4 external/mit/lua/dist/src/lvm.c
--- a/external/mit/lua/dist/src/lvm.c   Thu Jan 28 16:32:40 2016 +0000
+++ b/external/mit/lua/dist/src/lvm.c   Thu Jan 28 17:23:21 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lvm.c,v 1.9 2016/01/28 14:41:39 lneto Exp $    */
+/*     $NetBSD: lvm.c,v 1.10 2016/01/28 17:23:21 lneto Exp $   */
 
 /*
 ** Id: lvm.c,v 2.265 2015/11/23 11:30:45 roberto Exp 
@@ -203,18 +203,19 @@
   for (loop = 0; loop < MAXTAGLOOP; loop++) {
     const TValue *tm;
     if (oldval != NULL) {
-      lua_assert(ttistable(t) && ttisnil(oldval));
+      Table *h = hvalue(t);  /* save 't' table */
+      lua_assert(ttisnil(oldval));
       /* must check the metamethod */
-      if ((tm = fasttm(L, hvalue(t)->metatable, TM_NEWINDEX)) == NULL &&
+      if ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL &&
          /* no metamethod; is there a previous entry in the table? */
          (oldval != luaO_nilobject ||
          /* no previous entry; must create one. (The next test is
             always true; we only need the assignment.) */
-         (oldval = luaH_newkey(L, hvalue(t), key), 1))) {
+         (oldval = luaH_newkey(L, h, key), 1))) {
         /* no metamethod and (now) there is an entry with given key */
         setobj2t(L, cast(TValue *, oldval), val);
-        invalidateTMcache(hvalue(t));
-        luaC_barrierback(L, hvalue(t), val);
+        invalidateTMcache(h);
+        luaC_barrierback(L, h, val);
         return;
       }
       /* else will try the metamethod */



Home | Main Index | Thread Index | Old Index