From 2e14aa473ea20b485ed18f71c6ede2099c7b23cb Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 13 May 2015 17:41:50 +0100 Subject: Fix regexp splitting in lua. --- src/lua/lua_regexp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c index 48af6f7ab..18ceeb28a 100644 --- a/src/lua/lua_regexp.c +++ b/src/lua/lua_regexp.c @@ -491,6 +491,17 @@ lua_regexp_split (lua_State *L) } old_start = end; } + + if (len > 0 && (end == NULL || end < data + len)) { + if (end == NULL) { + end = data; + } + + lua_pushlstring (L, end, (data + len) - end); + lua_rawseti (L, -2, ++i); + matched = TRUE; + } + if (!matched) { lua_pop (L, 1); lua_pushnil (L); -- cgit v1.2.3