From 5cf30659bcad3f40b0b875bb61586eb30106b14c Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 15 Jun 2017 01:44:48 +1000 Subject: src/lstrlib.js: frontier looks past end of string expecting a null byte --- src/lstrlib.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lstrlib.js') 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 */ -- cgit v1.2.3-54-g00ecf