2
0
Эх сурвалжийг харах

Do not insert nil values into tables

Roberto Ierusalimschy 4 жил өмнө
parent
commit
553b37ce4f
1 өөрчлөгдсөн 2 нэмэгдсэн , 0 устгасан
  1. 2 0
      ltable.c

+ 2 - 0
ltable.c

@@ -647,6 +647,8 @@ void luaH_newkey (lua_State *L, Table *t, const TValue *key, TValue *value) {
     else if (unlikely(luai_numisnan(f)))
     else if (unlikely(luai_numisnan(f)))
       luaG_runerror(L, "table index is NaN");
       luaG_runerror(L, "table index is NaN");
   }
   }
+  if (ttisnil(value))
+    return;  /* do not insert nil values */
   mp = mainpositionTV(t, key);
   mp = mainpositionTV(t, key);
   if (!isempty(gval(mp)) || isdummy(t)) {  /* main position is taken? */
   if (!isempty(gval(mp)) || isdummy(t)) {  /* main position is taken? */
     Node *othern;
     Node *othern;