diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2026-07-24 11:21:24 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2026-07-24 11:21:24 -0300 |
| commit | e282da498cbf0bd5ea474b38bd61f6a1453d035d (patch) | |
| tree | caf499d6a6f37077c65fcbbea775d3c775aa061a /lstrlib.c | |
| parent | b18086ea3422ac89d1f7709dd7a37589040e233a (diff) | |
| download | lua-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.c | 3 |
1 files changed, 1 insertions, 2 deletions
| @@ -757,7 +757,6 @@ static int nospecials (const char *p, size_t l) { | |||
| 757 | static void prepstate (MatchState *ms, lua_State *L, | 757 | static 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 | ||
| 767 | static void reprepstate (MatchState *ms) { | 766 | static 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 | ||
