aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-06-18 23:33:37 +1000
committerdaurnimator <quae@daurnimator.com>2017-06-18 23:33:37 +1000
commitf813a48d45f231965050872534666fee73cbb053 (patch)
treeb81881bd575ab881778a5502b1dd8721eb7fcd25
parentfb7c8c189b7a864f5787a5ecfd3272fe0e99b0ad (diff)
downloadfengari-f813a48d45f231965050872534666fee73cbb053.tar.gz
fengari-f813a48d45f231965050872534666fee73cbb053.tar.bz2
fengari-f813a48d45f231965050872534666fee73cbb053.zip
src/lstrlib.js: Fix pack('s') using wrong constant
-rw-r--r--src/lstrlib.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index 4e499c9..e005bdc 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -608,7 +608,9 @@ const str_pack = function(L) {
case KOption.Kstring: { /* strings with length count */
let s = lauxlib.luaL_checkstring(L, arg);
let len = s.length;
- lauxlib.luaL_argcheck(L, size >= NB || len < (1 << size * NB), arg, lua.to_luastring("string length does not fit in given size", true));
+ lauxlib.luaL_argcheck(L, size >= 8 /* sizeof(size_t) */ ||
+ len < (1 << (size * NB)),
+ arg, lua.to_luastring("string length does not fit in given size", true));
packint(b, len, h.islittle, size, 0); /* pack length */
b.push(...s);
totalsize += len;