aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-07-07 11:55:12 +1000
committerdaurnimator <quae@daurnimator.com>2018-07-07 12:07:29 +1000
commitb9cb6c4fe614e16debddeed202f5ededc40719bf (patch)
tree81a531f12d7ffea43e4e7828fdad25ad6a5aeba0 /src
parentc60a1cbc5f76a147e74135add574a6a5d63eba7b (diff)
downloadfengari-b9cb6c4fe614e16debddeed202f5ededc40719bf.tar.gz
fengari-b9cb6c4fe614e16debddeed202f5ededc40719bf.tar.bz2
fengari-b9cb6c4fe614e16debddeed202f5ededc40719bf.zip
src/lundump.js: Fix reading empty string constants
Closes https://github.com/fengari-lua/fengari-interop/issues/42
Diffstat (limited to 'src')
-rw-r--r--src/lundump.js14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/lundump.js b/src/lundump.js
index cf3fafa..2213015 100644
--- a/src/lundump.js
+++ b/src/lundump.js
@@ -108,16 +108,12 @@ class BytecodeParser {
}
readString() {
- let size = Math.max(this.readByte() - 1, 0);
-
- if (size + 1 === 0xFF)
- size = this.readSize_t() - 1;
-
- if (size === 0) {
+ let size = this.readByte();
+ if (size === 0xFF)
+ size = this.readSize_t();
+ if (size === 0)
return null;
- }
-
- return luaS_bless(this.L, this.read(size));
+ return luaS_bless(this.L, this.read(size-1));
}
/* creates a mask with 'n' 1 bits at position 'p' */