From e6ca698ca4309632ab09826ad47492d2934e10bd Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Thu, 18 Oct 2012 19:54:20 +0100 Subject: [PATCH] regmatch(): add asserts for legal values of nextchr nextchr should always hold the next *byte* of the string, or the special value NEXTCHR_EOS, so assert this. And when we're moving to the next char, nextchr shouldn't already be NEXTCHR_EOS. --- regexec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/regexec.c b/regexec.c index f25bce1..0ee1c5a 100644 --- a/regexec.c +++ b/regexec.c @@ -3658,6 +3658,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) reenter_switch: SET_nextchr; + assert(nextchr < 256 && (nextchr >= 0 || nextchr == NEXTCHR_EOS)); switch (state_num) { case BOL: /* /^../ */ @@ -6326,6 +6327,7 @@ NULL /* this is a point to jump to in order to increment * locinput by one character */ increment_locinput: + assert(!NEXTCHR_IS_EOS); if (utf8_target) { locinput += PL_utf8skip[nextchr]; /* locinput is allowed to go 1 char off the end, but not 2+ */ -- 2.7.4