pollita Mon Feb 23 15:13:16 2004 EDT Modified files: /php-src/ext/standard string.c Log: Short circuit str_replaces when we already know that needle does not occur in haystack. Note: Prior bugfix was for #27176 not #27276 http://cvs.php.net/diff.php/php-src/ext/standard/string.c?r1=1.409&r2=1.410&ty=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.409 php-src/ext/standard/string.c:1.410 --- php-src/ext/standard/string.c:1.409 Mon Feb 23 15:06:01 2004 +++ php-src/ext/standard/string.c Mon Feb 23 15:13:14 2004 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.409 2004/02/23 20:06:01 pollita Exp $ */ +/* $Id: string.c,v 1.410 2004/02/23 20:13:14 pollita Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -3008,7 +3008,16 @@ o += needle_len; count++; } - new_str = safe_emalloc(count, str_len - needle_len, length + 1); + if (count == 0) { + /* Needle doesn't occur, shortcircuit the actual replacement. */ + new_str = estrndup(haystack, length); + if (_new_length) { + *_new_length = length; + } + return new_str; + } else { + new_str = safe_emalloc(count, str_len - needle_len, length + 1); + } } e = s = new_str;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php