diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-04-11 07:44:15 +0200 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-04-11 07:44:15 +0200 |
commit | c8cb77ea06cb2f1ca10cf63042a7cbea8d1c5e7a (patch) | |
tree | 7b6dbe3fd789efd73ce202bd5b3b03644e28f50f /src | |
parent | 7f8be9d514af9d5038a2a5e70d0c64592f4d3838 (diff) | |
download | fengari-c8cb77ea06cb2f1ca10cf63042a7cbea8d1c5e7a.tar.gz fengari-c8cb77ea06cb2f1ca10cf63042a7cbea8d1c5e7a.tar.bz2 fengari-c8cb77ea06cb2f1ca10cf63042a7cbea8d1c5e7a.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/lvm.js | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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: { |