From 8227b2b69230eaeea8f88d757b20021608518279 Mon Sep 17 00:00:00 2001 From: Hugo van der Sanden Date: Thu, 8 Aug 2019 17:27:14 +0100 Subject: [PATCH] [gh 17847] data->pos_delta should stick at infinity The expression we're about to add to data->pos_delta in this part of study_chunk() can be both positive or negative; however while we apply an overflow check to avoid exceeding OPTIMIZE_INFTY, we were happily subtracting from it when the expression was negative, making it no longer infinite. --- regcomp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/regcomp.c b/regcomp.c index 81fdffca7307..82fa2c07a5a7 100644 --- a/regcomp.c +++ b/regcomp.c @@ -5842,6 +5842,7 @@ Perl_re_printf( aTHX_ "LHS=%" UVuf " RHS=%" UVuf "\n", - minnext * mincount), (UV)(OPTIMIZE_INFTY - data->pos_delta)); #endif if (deltanext == OPTIMIZE_INFTY + || data->pos_delta == OPTIMIZE_INFTY || -counted * deltanext + (minnext + deltanext) * maxcount - minnext * mincount >= OPTIMIZE_INFTY - data->pos_delta) data->pos_delta = OPTIMIZE_INFTY; else