aboutsummaryrefslogtreecommitdiff
path: root/lstrlib.c
diff options
context:
space:
mode:
authorRoberto I <roberto@inf.puc-rio.br>2026-07-24 11:21:24 -0300
committerRoberto I <roberto@inf.puc-rio.br>2026-07-24 11:21:24 -0300
commite282da498cbf0bd5ea474b38bd61f6a1453d035d (patch)
treecaf499d6a6f37077c65fcbbea775d3c775aa061a /lstrlib.c
parentb18086ea3422ac89d1f7709dd7a37589040e233a (diff)
downloadlua-e282da498cbf0bd5ea474b38bd61f6a1453d035d.tar.gz
lua-e282da498cbf0bd5ea474b38bd61f6a1453d035d.tar.bz2
lua-e282da498cbf0bd5ea474b38bd61f6a1453d035d.zip
Bug: wrong initialization in result from 'gmatch'
Function returned by 'string.gmatch' can be left in an inconsistent state after an error.
Diffstat (limited to 'lstrlib.c')
-rw-r--r--lstrlib.c3
1 files changed, 1 insertions, 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) {
757static void prepstate (MatchState *ms, lua_State *L, 757static void prepstate (MatchState *ms, lua_State *L,
758 const char *s, size_t ls, const char *p, size_t lp) { 758 const char *s, size_t ls, const char *p, size_t lp) {
759 ms->L = L; 759 ms->L = L;
760 ms->matchdepth = MAXCCALLS;
761 ms->src_init = s; 760 ms->src_init = s;
762 ms->src_end = s + ls; 761 ms->src_end = s + ls;
763 ms->p_end = p + lp; 762 ms->p_end = p + lp;
@@ -765,8 +764,8 @@ static void prepstate (MatchState *ms, lua_State *L,
765 764
766 765
767static void reprepstate (MatchState *ms) { 766static void reprepstate (MatchState *ms) {
767 ms->matchdepth = MAXCCALLS;
768 ms->level = 0; 768 ms->level = 0;
769 lua_assert(ms->matchdepth == MAXCCALLS);
770} 769}
771 770
772 771