From 06c1e428b32765bd77f8282acf4fed84cccc5922 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Fri, 16 Jun 2017 11:50:25 +0200 Subject: unpacknum should only look at the first 'size' bytes --- src/lstrlib.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') 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); -- cgit v1.2.3-70-g09d2