summaryrefslogtreecommitdiff
blob: 46218a1f4614067ea1e393ade4d9829a378bb585 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Fix from upstream to fix a corner case segfault.

http://bugs.gentoo.org/95495

--- grep-2.5.1/src/search.c
+++ grep-2.5.1/src/search.c
@@ -701,8 +701,10 @@
       char eol = eolbyte;
       if (!exact)
 	{
-	  end = memchr (end, eol, buflim - end);
-	  end++;
+	  if (!(end = memchr (end, eol, buflim - end)))
+	    end = buflim;
+	  else
+	    end++;
 	  while (buf < beg && beg[-1] != eol)
 	    --beg;
 	}