aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-06-16 11:50:25 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-06-16 11:50:25 +0200
commit06c1e428b32765bd77f8282acf4fed84cccc5922 (patch)
tree3ae25ad7d5fdf72c63429f30395d65e1ccac6238 /src
parent78b50f7261595ec645312353406df23e9c1274e4 (diff)
downloadfengari-06c1e428b32765bd77f8282acf4fed84cccc5922.tar.gz
fengari-06c1e428b32765bd77f8282acf4fed84cccc5922.tar.bz2
fengari-06c1e428b32765bd77f8282acf4fed84cccc5922.zip
unpacknum should only look at the first 'size' bytes
Diffstat (limited to 'src')
-rw-r--r--src/lstrlib.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index 248d245..a4a5289 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -747,7 +747,8 @@ const unpacknum = function(L, b, islittle, size) {
assert(b.length >= size);
let dv = new DataView(new ArrayBuffer(size));
- b.forEach((e, i) => dv.setUint8(i, e, islittle));
+ for (let i = 0; i < size; i++)
+ dv.setUint8(i, b[i], islittle);
if (size == 4) return dv.getFloat32(0, islittle);
else return dv.getFloat64(0, islittle);