]> granicus.if.org Git - php/commitdiff
Fixed bug #42142 (substr_replace() returns FALSE when length > string
authorIlia Alshanetsky <iliaa@php.net>
Mon, 30 Jul 2007 14:22:06 +0000 (14:22 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 30 Jul 2007 14:22:06 +0000 (14:22 +0000)
length).

[doc] Adjust length validation check inside substr_replace() to be similar
to that inside substr() so that excessive length is truncated to string
length.

NEWS
ext/standard/string.c

diff --git a/NEWS b/NEWS
index 3eae7a5ab0d838287df8a53f5a7d877a917f10b8..054d8cc093b5d5481f3db9d1fee0a26c3decc1ac 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -70,6 +70,8 @@ PHP                                                                        NEWS
 - Fixed PECL bug #11216 (crash in ZipArchive::addEmptyDir when a directory 
   already exists). (Pierre)
 
+- Fixed bug #42142 (substr_replace() returns FALSE when length > string
+  length). (Ilia) 
 - Fixed bug #42135 (Second call of session_start() causes creation of SID).
   (Ilia)
 - Fixed Bug #42112 (deleting a node produces memory corruption). (Rob)
index 4436b5a7aa1d9fde0ea8c190e9a2ce1caee48429..2617c681b351df0cc332ab278822f1fb4e4022d8 100644 (file)
@@ -2226,7 +2226,7 @@ PHP_FUNCTION(substr_replace)
                        if (f > Z_STRLEN_PP(str) || (f < 0 && -f > Z_STRLEN_PP(str))) {
                                RETURN_FALSE;
                        } else if (l > Z_STRLEN_PP(str) || (l < 0 && -l > Z_STRLEN_PP(str))) {
-                               RETURN_FALSE;
+                               l = Z_STRLEN_PP(str);
                        }
 
                        if ((f + l) > Z_STRLEN_PP(str)) {