From: Antony Dovgal Date: Fri, 20 May 2005 14:23:42 +0000 (+0000) Subject: fix bug #33076 (str_ireplace() incorrectly counts result string length and may cause... X-Git-Tag: php-5.0.1b1~204 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ce95ef1eaa6bca3255cd481346a25071928612b;p=php fix bug #33076 (str_ireplace() incorrectly counts result string length and may cause segfault) add test --- diff --git a/ext/standard/string.c b/ext/standard/string.c index 36c3c223c3..e65930f04d 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2991,7 +2991,7 @@ PHPAPI int php_char_to_str_ex(char *str, uint len, char from, char *to, int to_l char *source, *target, *tmp, *source_end=str+len, *tmp_end = NULL; for (source = str; source < source_end; source++) { - if (*source == from) { + if ((case_sensitivity && *source == from) || (!case_sensitivity && tolower(*source) == tolower(from))) { char_count++; } } diff --git a/ext/standard/tests/strings/bug33076.phpt b/ext/standard/tests/strings/bug33076.phpt new file mode 100644 index 0000000000..dafb8161b0 --- /dev/null +++ b/ext/standard/tests/strings/bug33076.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #33076 (str_ireplace() incorrectly counts result string length and may cause segfault) +--FILE-- + +--EXPECT-- +string(6) "bzexbz" +Done