|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-03-24 10:24 UTC] marcel at korton dot nl
Description:
------------
str_ireplace gives an unexpected result
Reproduce code:
---------------
<?php
$strResult = '/*<B>i see this</B>*/';
echo $strResult;
$strResult = str_ireplace('/*<B>', '<B>', $strResult );
echo $strResult;
?>
Expected result:
----------------
<B>i see this</B>*/'
Actual result:
--------------
PHP has encountered an Access Violation at 00CB7C21/*i see this*/
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 10:00:01 2025 UTC |
Verified the problem. The following patch fixes it for me. Index: string.c =================================================================== RCS file: /repository/php-src/ext/standard/string.c,v retrieving revision 1.413 diff -u -r1.413 string.c --- string.c 18 Mar 2004 09:48:37 -0000 1.413 +++ string.c 26 Mar 2004 01:46:19 -0000 @@ -3065,6 +3065,10 @@ e += end - p; } } else { + haystack_dup = estrndup(haystack, length); + needle_dup = estrndup(needle, needle_len); + php_strtolower(haystack_dup, length); + php_strtolower(needle_dup, needle_len); end = haystack_dup + length; for (p = haystack_dup; (r = php_memnstr(p, needle_dup, needle_len, end)); p = r + needle_len) {