# HG changeset patch # User MRAB # Date 1358283982 0 # Node ID 02a02b8dfb0aa2531ef9b89fece2ea7274375346 # Parent 2d764503dec3031b16d421376c6e5d75eeff8d7a Issue #9669: regexp: zero-width matches in MIN_UNTIL diff -r 2d764503dec3 -r 02a02b8dfb0a Modules/_sre.c --- a/Modules/_sre.c Mon Jan 07 18:03:29 2013 +0000 +++ b/Modules/_sre.c Tue Jan 15 21:06:22 2013 +0000 @@ -1272,13 +1272,18 @@ LASTMARK_RESTORE(); - if (ctx->count >= ctx->u.rep->pattern[2] - && ctx->u.rep->pattern[2] != 65535) + if ((ctx->count >= ctx->u.rep->pattern[2] + && ctx->u.rep->pattern[2] != 65535) || + state->ptr == ctx->u.rep->last_ptr) RETURN_FAILURE; ctx->u.rep->count = ctx->count; + /* zero-width match protection */ + DATA_PUSH(&ctx->u.rep->last_ptr); + ctx->u.rep->last_ptr = state->ptr; DO_JUMP(JUMP_MIN_UNTIL_3,jump_min_until_3, ctx->u.rep->pattern+3); + DATA_POP(&ctx->u.rep->last_ptr); if (ret) { RETURN_ON_ERROR(ret); RETURN_SUCCESS;