summaryrefslogtreecommitdiff
path: root/src/ldo.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-05-05 15:24:00 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-05-05 15:41:29 +0200
commit7ef345bee73f6cc843b0d82866d036a3ac5829ca (patch)
tree11b170164238126952f3c790e18a74a7af629d48 /src/ldo.js
parent818a86ae8e4afe75f0521967125cdf1cca6b26f0 (diff)
downloadfengari-7ef345bee73f6cc843b0d82866d036a3ac5829ca.tar.gz
fengari-7ef345bee73f6cc843b0d82866d036a3ac5829ca.tar.bz2
fengari-7ef345bee73f6cc843b0d82866d036a3ac5829ca.zip
Binary chunk can be a lua string (string.dump)
Diffstat (limited to 'src/ldo.js')
-rw-r--r--src/ldo.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ldo.js b/src/ldo.js
index 9ef8b66..13bd15c 100644
--- a/src/ldo.js
+++ b/src/ldo.js
@@ -574,7 +574,9 @@ const f_parser = function(L, p) {
let c = p.z.getc(); /* read first character */
if (c === defs.LUA_SIGNATURE.charCodeAt(0)) {
checkmode(L, p.mode, defs.to_luastring("binary", true));
- cl = new BytecodeParser(L, p.z.buffer, p.name).luaU_undump();
+ let buff = p.z.buffer;
+ if (Array.isArray(buff)) buff = new DataView(new Uint8Array(p.z.buffer).buffer); /* Lua string holding binary (string.dump) */
+ cl = new BytecodeParser(L, buff, p.name).luaU_undump();
} else {
checkmode(L, p.mode, defs.to_luastring("text", true));
cl = lparser.luaY_parser(L, p.z, p.buff, p.dyd, p.name, c);