From f813a48d45f231965050872534666fee73cbb053 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 18 Jun 2017 23:33:37 +1000 Subject: src/lstrlib.js: Fix pack('s') using wrong constant --- src/lstrlib.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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; -- cgit v1.2.3-70-g09d2