From: Richard Stallman Date: Sun, 1 Oct 1995 20:17:02 +0000 (+0000) Subject: (re_search_2): Use 0, not -1, as the lower bound X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58d50470ab1a18a4334189fdf4ab9cd95f440c66;p=pspp (re_search_2): Use 0, not -1, as the lower bound for the match position when we adjust RANGE. --- diff --git a/regex.c b/regex.c index d0086ed1aa..8b26a73755 100644 --- a/regex.c +++ b/regex.c @@ -3259,9 +3259,10 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) 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;