Index: string.c =================================================================== RCS file: /repository/php4/ext/standard/string.c,v retrieving revision 1.308 diff -u -3 -p -r1.308 string.c --- string.c 3 Oct 2002 18:15:18 -0000 1.308 +++ string.c 4 Oct 2002 01:43:19 -0000 @@ -2423,10 +2423,13 @@ PHPAPI char *php_addslashes(char *str, i return str; } new_str = (char *) emalloc((length?length:(length=strlen(str)))*2+1); + source = str; + end = source + length; + target = new_str; + if (PG(magic_quotes_sybase)) { - for (source = str, end = source+length, target = new_str; source < end; source++) { - c = *source; - switch (c) { + while (source end) - return NULL; - if (memcmp(p, needle, needle_len) == 0) - return p; + if ((p = memchr(p, *needle, (end-p))) && ne == p[needle_len-1]) { + if (!memcmp(needle, p, needle_len-1)) { + return p; + } + } + + if (p == NULL) { + return NULL; + } + p++; } + return NULL; }