about summary refs log tree commit diff
path: root/posix
diff options
context:
space:
mode:
Diffstat (limited to 'posix')
-rw-r--r--posix/regexec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/posix/regexec.c b/posix/regexec.c
index 8988c6633c..7e3a8320b1 100644
--- a/posix/regexec.c
+++ b/posix/regexec.c
@@ -357,10 +357,12 @@ re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
   int eflags = 0;
 
   /* Check for out-of-range.  */
-  if (BE (start < 0 || start > length || range < 0, 0))
+  if (BE (start < 0 || start > length, 0))
     return -1;
   if (BE (start + range > length, 0))
     range = length - start;
+  else if (BE (start + range < 0, 0))
+    range = -start;
 
   eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
   eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;