From c8cb77ea06cb2f1ca10cf63042a7cbea8d1c5e7a Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Tue, 11 Apr 2017 07:44:15 +0200 Subject: Constant must be copied ! This fixes an issue where a single constant reference was used in several stack slot resulting in some rather funny things in the VM loop. --- src/lvm.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lvm.js b/src/lvm.js index 3697008..ad1e807 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -137,12 +137,14 @@ const luaV_execute = function(L) { break; } case OCi.OP_LOADK: { - L.stack[ra] = k[i.Bx]; + let konst = k[i.Bx]; + L.stack[ra] = new TValue(konst.type, konst.value); break; } case OCi.OP_LOADKX: { assert(ci.u.l.savedpc[ci.pcOff].opcode === OCi.OP_EXTRAARG); - L.stack[ra] = k[ci.u.l.savedpc[ci.pcOff++].Ax]; + let konst = k[ci.u.l.savedpc[ci.pcOff++].Ax]; + L.stack[ra] = new TValue(konst.type, konst.value); break; } case OCi.OP_LOADBOOL: { -- cgit v1.2.3-70-g09d2