Skip to content

Commit

Permalink
PATCH: [perl #133999] Assertion failure in regex match
Browse files Browse the repository at this point in the history
This was caused by failing to limit matching to within the bounds of the
target string.  I'm pretty sure this bug has long been there, but was
exposed by the recently added wildcard property matching feature.
  • Loading branch information
khwilliamson committed Apr 10, 2019
1 parent 0a5ed81 commit b92b270
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 6 additions & 3 deletions regexec.c
Expand Up @@ -1972,9 +1972,12 @@ STMT_START {
}

/* This is the macro to use when we want to see if something that looks like it
* could match, actually does, and if so exits the loop */
#define REXEC_FBC_TRYIT \
if ((reginfo->intuit || regtry(reginfo, &s))) \
* could match, actually does, and if so exits the loop. It needs to be used
* only for bounds checking macros, as it allows for matching beyond the end of
* string (which should be zero length without having to look at the string
* contents) */
#define REXEC_FBC_TRYIT \
if ((reginfo->intuit || (s <= reginfo->strend && regtry(reginfo, &s)))) \
goto got_it

/* The only difference between the BOUND and NBOUND cases is that
Expand Down
7 changes: 7 additions & 0 deletions t/re/pat_advanced.t
Expand Up @@ -2505,6 +2505,13 @@ EOF
ok(! $?, "User-defined pattern did not cause panic [perl 130010]");
}

{ # [perl #133999] Previously assertion failure
fresh_perl_like('0 =~ /\p{nv:(\B(*COMMIT)C+)}/',
qr/No Unicode property value wildcard matches/,
{},
"Assertion failure with *COMMIT and wildcard property");
}


# !!! NOTE that tests that aren't at all likely to crash perl should go
# a ways above, above these last ones. There's a comment there that, like
Expand Down

0 comments on commit b92b270

Please sign in to comment.