diff options
-rw-r--r-- | src/lstrlib.js | 4 | ||||
-rw-r--r-- | tests/test-suite/inprogress/tpack.js | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js index b21690b..4e499c9 100644 --- a/src/lstrlib.js +++ b/src/lstrlib.js @@ -587,8 +587,8 @@ const str_pack = function(L) { case KOption.Kuint: { /* unsigned integers */ let n = lauxlib.luaL_checkinteger(L, arg); if (size < SZINT) - lauxlib.luaL_argcheck(L, n < (1 << (size * NB)), arg, lua.to_luastring("unsigned overflow", true)); - packint(b, n, h.islittle, size, false); + lauxlib.luaL_argcheck(L, (n>>>0) < (1 << (size * NB)), arg, lua.to_luastring("unsigned overflow", true)); + packint(b, n>>>0, h.islittle, size, false); break; } case KOption.Kfloat: { /* floating-point options */ diff --git a/tests/test-suite/inprogress/tpack.js b/tests/test-suite/inprogress/tpack.js index b5ae5a9..e624cce 100644 --- a/tests/test-suite/inprogress/tpack.js +++ b/tests/test-suite/inprogress/tpack.js @@ -364,9 +364,8 @@ test("[test-suite] tpack: overflow in packing", function (t) { local umax = (1 << (i * 8)) - 1 local max = umax >> 1 local min = ~max - -- TODO: unsigned overflow - -- checkerror("overflow", pack, "<I" .. i, -1) - -- checkerror("overflow", pack, "<I" .. i, min) + checkerror("overflow", pack, "<I" .. i, -1) + checkerror("overflow", pack, "<I" .. i, min) checkerror("overflow", pack, ">I" .. i, umax + 1) checkerror("overflow", pack, ">i" .. i, umax) |