File: 002_strstr_needle_in_haystack.patch

package info (click to toggle)
tf5 5.0beta7-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 728 kB
  • ctags: 5
  • sloc: sh: 28; makefile: 23
file content (18 lines) | stat: -rw-r--r-- 881 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# This patch fixes a problem in the replace() function; the original code
# relies on broken behavior found in some older versions of the libc
# strstr() function, where passing in an empty string ("", not null)
# resulted in getting back a null (no match) rather than a pointer to the
# base of the original string (match the first 'empty sequence' should
# always trigger at the start of the string in PCREs).

--- src/expr.c.orig	2005-10-17 12:19:50.766595686 -0600
+++ src/expr.c	2005-10-17 12:21:01.725322349 -0600
@@ -1359,7 +1359,7 @@
 	    constr = opdstr(1);
 	    Sstr2 = Stringnew(NULL, -1, constr->attrs);
 	    start = constr->data;
-	    while ((next = strstr(start, old->data))) {
+	    while (old->len && (next = strstr(start, old->data))) {
 		SStringoncat(Sstr2, constr, start - constr->data, next - start);
 		SStringcat(Sstr2, new);
 		start = next + old->len;