diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-11-18 11:43:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-18 11:43:44 (GMT) |
commit | f9c5573dedcb2f2e9ae152672ce157987cdea612 (patch) | |
tree | 9c65e6d8d719e45951d2d55bd5da72f60c93fc8e /Modules | |
parent | 7538e7f5696408fa0aa02fce8a413a7dfac76a04 (diff) | |
download | cpython-f9c5573dedcb2f2e9ae152672ce157987cdea612.zip cpython-f9c5573dedcb2f2e9ae152672ce157987cdea612.tar.gz cpython-f9c5573dedcb2f2e9ae152672ce157987cdea612.tar.bz2 |
gh-101955: Fix SystemError in possesive quantifier with alternative and group (GH-111362)
Co-authored-by: <wjssz@users.noreply.github.com>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_sre/sre_lib.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Modules/_sre/sre_lib.h b/Modules/_sre/sre_lib.h index 0c93f51..af4bfc5 100644 --- a/Modules/_sre/sre_lib.h +++ b/Modules/_sre/sre_lib.h @@ -1306,6 +1306,17 @@ dispatch: pointer */ state->ptr = ptr; + /* Set state->repeat to non-NULL */ + ctx->u.rep = repeat_pool_malloc(state); + if (!ctx->u.rep) { + RETURN_ERROR(SRE_ERROR_MEMORY); + } + ctx->u.rep->count = -1; + ctx->u.rep->pattern = NULL; + ctx->u.rep->prev = state->repeat; + ctx->u.rep->last_ptr = NULL; + state->repeat = ctx->u.rep; + /* Initialize Count to 0 */ ctx->count = 0; @@ -1320,6 +1331,9 @@ dispatch: } else { state->ptr = ptr; + /* Restore state->repeat */ + state->repeat = ctx->u.rep->prev; + repeat_pool_free(state, ctx->u.rep); RETURN_FAILURE; } } @@ -1392,6 +1406,10 @@ dispatch: } } + /* Restore state->repeat */ + state->repeat = ctx->u.rep->prev; + repeat_pool_free(state, ctx->u.rep); + /* Evaluate Tail */ /* Jump to end of pattern indicated by skip, and then skip the SUCCESS op code that follows it. */ |