summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2017-03-25 15:00:22 -0600
committerKarl Williamson <khw@cpan.org>2017-11-06 14:31:45 -0700
commit43b2f4ef399e2fd7240b4eeb0658686ad95f8e62 (patch)
tree3fa924dbbbad21de75dae6b88ef050688d859400 /regcomp.c
parentaea1585ca7b05ce6e4dab68540664e1e16bb3007 (diff)
downloadperl-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.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/regcomp.c b/regcomp.c
index 892aed82cd..9aec81ddfa 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -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);