Bug: wrong initialization in result from 'gmatch'

Function returned by 'string.gmatch' can be left in an inconsistent
state after an error.
This commit is contained in:
Roberto I
2026-07-24 11:21:24 -03:00
parent b18086ea34
commit e282da498c

View File

@@ -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);
}