From f7022b5a04f3da75047662acc8b74229a3406a09 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sat, 8 Feb 2014 12:54:27 +0000 Subject: [PATCH] re_intuit_start(): assert fixed+float dont overlap Currently it appears that the anchored and floating substring ranges don't overlap. Assert this truth; it will force someone to audit the code first if they wish to change that assumption. --- regexec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/regexec.c b/regexec.c index cd74d5f..fbbba8a 100644 --- a/regexec.c +++ b/regexec.c @@ -673,6 +673,17 @@ Perl_re_intuit_start(pTHX_ assert(prog->substrs->data[2].min_offset >= 0); assert(prog->substrs->data[2].max_offset >= 0); + /* for now, assume that if both present, that the floating substring + * follows the anchored substring, and that they don't overlap. + * If you break this assumption (e.g. doing better optimisations + * with lookahead/behind), then you'll need to audit the code in this + * function carefully first + */ + assert( + ! ( (prog->anchored_utf8 || prog->anchored_substr) + && (prog->float_utf8 || prog->float_substr)) + || (prog->float_min_offset >= prog->anchored_offset)); + /* CHR_DIST() would be more correct here but it makes things slow. */ if (prog->minlen > strend - strpos) { DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, -- 2.7.4