Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 166878f

Browse files
committed
Fixing bug #1072259 in SRE.
1 parent 4901a1f commit 166878f

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

Modules/_sre.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,9 +1024,10 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern)
10241024

10251025
state->ptr = ctx->ptr;
10261026

1027-
ctx->count = SRE_COUNT(state, ctx->pattern+3, ctx->pattern[2]);
1028-
RETURN_ON_ERROR(ctx->count);
1029-
1027+
ret = SRE_COUNT(state, ctx->pattern+3, ctx->pattern[2]);
1028+
RETURN_ON_ERROR(ret);
1029+
DATA_LOOKUP_AT(SRE_MATCH_CONTEXT, ctx, ctx_pos);
1030+
ctx->count = ret;
10301031
ctx->ptr += ctx->count;
10311032

10321033
/* when we arrive here, count contains the number of
@@ -1110,13 +1111,14 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern)
11101111
ctx->count = 0;
11111112
else {
11121113
/* count using pattern min as the maximum */
1113-
ctx->count = SRE_COUNT(state, ctx->pattern+3,
1114-
ctx->pattern[1]);
1115-
RETURN_ON_ERROR(ctx->count);
1116-
if (ctx->count < (int) ctx->pattern[1])
1114+
ret = SRE_COUNT(state, ctx->pattern+3, ctx->pattern[1]);
1115+
RETURN_ON_ERROR(ret);
1116+
DATA_LOOKUP_AT(SRE_MATCH_CONTEXT, ctx, ctx_pos);
1117+
if (ret < (int) ctx->pattern[1])
11171118
/* didn't match minimum number of times */
11181119
RETURN_FAILURE;
11191120
/* advance past minimum matches of repeat */
1121+
ctx->count = ret;
11201122
ctx->ptr += ctx->count;
11211123
}
11221124

@@ -1140,6 +1142,7 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern)
11401142
state->ptr = ctx->ptr;
11411143
ret = SRE_COUNT(state, ctx->pattern+3, 1);
11421144
RETURN_ON_ERROR(ret);
1145+
DATA_LOOKUP_AT(SRE_MATCH_CONTEXT, ctx, ctx_pos);
11431146
if (ret == 0)
11441147
break;
11451148
assert(ret == 1);

0 commit comments

Comments
 (0)