diff options
author | Karl Williamson <khw@cpan.org> | 2017-03-25 15:00:22 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2017-11-06 14:31:45 -0700 |
commit | 43b2f4ef399e2fd7240b4eeb0658686ad95f8e62 (patch) | |
tree | 3fa924dbbbad21de75dae6b88ef050688d859400 /regcomp.c | |
parent | aea1585ca7b05ce6e4dab68540664e1e16bb3007 (diff) | |
download | perl-43b2f4ef399e2fd7240b4eeb0658686ad95f8e62.tar.gz |
regcomp.c: Convert some strchr to memchr
This allows things to work properly in the face of embedded NULs.
See the branch merge message for more information.
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -12056,7 +12056,7 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state, RExC_parse++; /* Skip past the '{' */ - endbrace = strchr(RExC_parse, '}'); + endbrace = (char *) memchr(RExC_parse, '}', RExC_end - RExC_parse); if (! endbrace) { /* no trailing brace */ vFAIL2("Missing right brace on \\%c{}", 'N'); } @@ -12773,9 +12773,11 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth) else { STRLEN length; char name = *RExC_parse; - char * endbrace; + char * endbrace = NULL; RExC_parse += 2; - endbrace = strchr(RExC_parse, '}'); + if (RExC_parse < RExC_end) { + endbrace = (char *) memchr(RExC_parse, '}', RExC_end - RExC_parse); + } if (! endbrace) { vFAIL2("Missing right brace on \\%c{}", name); @@ -16312,7 +16314,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth, vFAIL2("Empty \\%c", (U8)value); if (*RExC_parse == '{') { const U8 c = (U8)value; - e = strchr(RExC_parse, '}'); + e = (char *) memchr(RExC_parse, '}', RExC_end - RExC_parse); if (!e) { RExC_parse++; vFAIL2("Missing right brace on \\%c{}", c); |