From 3347bd096a26845b7b855cd1b3691facde142f11 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Mon, 9 Oct 2017 13:18:16 +1100 Subject: [PATCH] Apply Lua.org patch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dead keys with nil values can stay in weak tables. reported by 云风 Cloud Wu on 15 Aug 2017. existed since 5.2. Example: See https://www.lua.org/bugs.html#5.3.4-5. --- src/lua/lgc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lua/lgc.cpp b/src/lua/lgc.cpp index ba2c19e14e94..00b87e2e6712 100644 --- a/src/lua/lgc.cpp +++ b/src/lua/lgc.cpp @@ -643,8 +643,9 @@ static void clearkeys (global_State *g, GCObject *l, GCObject *f) { for (n = gnode(h, 0); n < limit; n++) { if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) { setnilvalue(gval(n)); /* remove value ... */ - removeentry(n); /* and remove entry from table */ } + if (ttisnil(gval(n))) /* is entry empty? */ + removeentry(n); /* remove entry from table */ } } }