From e282da498cbf0bd5ea474b38bd61f6a1453d035d Mon Sep 17 00:00:00 2001 From: Roberto I Date: Fri, 24 Jul 2026 11:21:24 -0300 Subject: [PATCH] Bug: wrong initialization in result from 'gmatch' Function returned by 'string.gmatch' can be left in an inconsistent state after an error. --- lstrlib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lstrlib.c b/lstrlib.c index 03167161..f748bf88 100644 --- a/lstrlib.c +++ b/lstrlib.c @@ -757,7 +757,6 @@ static int nospecials (const char *p, size_t l) { static void prepstate (MatchState *ms, lua_State *L, const char *s, size_t ls, const char *p, size_t lp) { ms->L = L; - ms->matchdepth = MAXCCALLS; ms->src_init = s; ms->src_end = s + ls; ms->p_end = p + lp; @@ -765,8 +764,8 @@ static void prepstate (MatchState *ms, lua_State *L, static void reprepstate (MatchState *ms) { + ms->matchdepth = MAXCCALLS; ms->level = 0; - lua_assert(ms->matchdepth == MAXCCALLS); }