aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-06-16 12:19:18 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-06-16 12:19:18 +0200
commit0bdf4d229431dfa241e6fd4d63d144d944f99cfe (patch)
tree30bdb058c27e0bf72da646e4ab97c9e1c7b19bbc
parent06c1e428b32765bd77f8282acf4fed84cccc5922 (diff)
downloadfengari-0bdf4d229431dfa241e6fd4d63d144d944f99cfe.tar.gz
fengari-0bdf4d229431dfa241e6fd4d63d144d944f99cfe.tar.bz2
fengari-0bdf4d229431dfa241e6fd4d63d144d944f99cfe.zip
str_unpack: pos is size_t in C so -1 should raise initial position error
-rw-r--r--src/lstrlib.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index a4a5289..7c3fac4 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -764,7 +764,7 @@ const str_unpack = function(L) {
let ld = data.length;
let pos = posrelat(lauxlib.luaL_optinteger(L, 3, 1), ld) - 1;
let n = 0; /* number of results */
- lauxlib.luaL_argcheck(L, pos <= ld, 3, lua.to_luastring("initial position out of string", true));
+ lauxlib.luaL_argcheck(L, pos <= ld && pos >= 0, 3, lua.to_luastring("initial position out of string", true));
while (fmt.off < fmt.s.length) {
let details = getdetails(h, pos, fmt);
let opt = details.opt;