summaryrefslogtreecommitdiff
path: root/src/lstrlib.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-06-15 01:44:48 +1000
committerdaurnimator <quae@daurnimator.com>2017-06-15 01:44:48 +1000
commit5cf30659bcad3f40b0b875bb61586eb30106b14c (patch)
tree07453882dbcf89c426b2dc3449436b9b9965f0e9 /src/lstrlib.js
parent5dd31ddd7032687bbce138f23dcd08bc146942fc (diff)
downloadfengari-5cf30659bcad3f40b0b875bb61586eb30106b14c.tar.gz
fengari-5cf30659bcad3f40b0b875bb61586eb30106b14c.tar.bz2
fengari-5cf30659bcad3f40b0b875bb61586eb30106b14c.zip
src/lstrlib.js: frontier looks past end of string expecting a null byte
Diffstat (limited to 'src/lstrlib.js')
-rw-r--r--src/lstrlib.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index d3373a4..ba1ef55 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -1044,13 +1044,13 @@ const match = function(ms, s, p) {
}
break;
}
- case 'f'.charCodeAt(0): {
+ case 'f'.charCodeAt(0): { /* frontier? */
p += 2;
if (ms.p[p] !== '['.charCodeAt(0))
lauxlib.luaL_error(ms.L, lua.to_luastring("missing '[' after '%%f' in pattern"));
let ep = classend(ms, p); /* points to what is next */
let previous = s === ms.src_init ? 0 : ms.src[s-1];
- if (!matchbracketclass(ms, previous, p, ep - 1) && matchbracketclass(ms, ms.src[s], p, ep - 1)) {
+ if (!matchbracketclass(ms, previous, p, ep - 1) && matchbracketclass(ms, (s===ms.src_end)?0:ms.src[s], p, ep - 1)) {
p = ep; gotoinit = true; break;
}
s = null; /* match failed */