# HG changeset patch # User Jim Meyering # Date 814026674 0 # Node ID 68b8d9f8bf1a6a4cb4b42ead11673d2c46c0d80a # Parent 39f6e38131a6bb9340398449dbb9015785e52377 Merge latest change from FSF. diff --git a/lib/regex.c b/lib/regex.c --- a/lib/regex.c +++ b/lib/regex.c @@ -3265,9 +3265,10 @@ return -1; /* Fix up RANGE if it might eventually take us outside - the virtual concatenation of STRING1 and STRING2. */ - if (endpos < -1) - range = -1 - startpos; + the virtual concatenation of STRING1 and STRING2. + Make sure we won't move STARTPOS below 0 or above TOTAL_SIZE. */ + if (endpos < 0) + range = 0 - startpos; else if (endpos > total_size) range = total_size - startpos;