]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Preserve keys with dynamic values in template tables when saving bytecode.
authorMike Pall <mike>
Wed, 31 Jan 2024 13:32:04 +0000 (14:32 +0100)
committerMike Pall <mike>
Wed, 31 Jan 2024 13:32:04 +0000 (14:32 +0100)
Reported by Lyrthras. Fixed by Peter Cawley. #1155

src/lj_bcwrite.c

index 6282f7670865456a8dfab059a839d443530b9fd0..9820ad122bffc412d07c413d1e85d1ae90eb2564 100644 (file)
@@ -124,7 +124,7 @@ static void bcwrite_ktab(BCWriteCtx *ctx, const GCtab *t)
     MSize i, hmask = t->hmask;
     Node *node = noderef(t->node);
     for (i = 0; i <= hmask; i++)
-      nhash += !tvisnil(&node[i].val);
+      nhash += !tvisnil(&node[i].key);
   }
   /* Write number of array slots and hash slots. */
   bcwrite_uleb128(ctx, narray);
@@ -139,7 +139,7 @@ static void bcwrite_ktab(BCWriteCtx *ctx, const GCtab *t)
     MSize i = nhash;
     Node *node = noderef(t->node) + t->hmask;
     for (;; node--)
-      if (!tvisnil(&node->val)) {
+      if (!tvisnil(&node->key)) {
        bcwrite_ktabk(ctx, &node->key, 0);
        bcwrite_ktabk(ctx, &node->val, 1);
        if (--i == 0) break;