aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-06-16 10:43:05 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-06-16 10:43:05 +0200
commitbafedc76663a9a5ead715b2f0add27b88c029785 (patch)
tree8ffd57fe507483ae94531613b1e29d8f926f7111
parent83eadc932dd0100a7dac254d8ba92a7e02deddd8 (diff)
downloadfengari-bafedc76663a9a5ead715b2f0add27b88c029785.tar.gz
fengari-bafedc76663a9a5ead715b2f0add27b88c029785.tar.bz2
fengari-bafedc76663a9a5ead715b2f0add27b88c029785.zip
Fix bad test on issigned in unpackint
-rw-r--r--src/lstrlib.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index 6ea1630..f2518e0 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -733,7 +733,7 @@ const unpackint = function(L, str, islittle, size, issigned) {
res = ((res ^ mask) - mask); /* do sign extension */
}
} else if (size > SZINT) { /* must check unread bytes */
- let mask = issigned || res >= 0 ? 0 : MC;
+ let mask = !issigned || res >= 0 ? 0 : MC;
for (let i = limit; i < size; i++) {
if (str[islittle ? i : size - 1 - i] !== mask)
lauxlib.luaL_error(L, lua.to_luastring("%d-byte integer does not fit into Lua Integer"), size);