]> granicus.if.org Git - php/commitdiff
Fixed bug #42208 (substr_replace() crashes when the same array is passed
authorIlia Alshanetsky <iliaa@php.net>
Sun, 5 Aug 2007 14:47:42 +0000 (14:47 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 5 Aug 2007 14:47:42 +0000 (14:47 +0000)
more than once)

NEWS
ext/standard/string.c
ext/standard/tests/strings/bug42208.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 086e9b29918053aab6674da3c02eb4593e197d9f..7a3092eb8069865fde6dfbfbc88f65a66e9980f4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Aug 2007, PHP 5.2.4
+- Fixed bug #42208 (substr_replace() crashes when the same array is passed 
+  more than once). (crrodriguez at suse dot de, Ilia)
 - Fixed bug #36492 (Userfilters can leak buckets). (Sara)
 
 02 Aug 2007, PHP 5.2.4RC1
index 2617c681b351df0cc332ab278822f1fb4e4022d8..e7b36a27acd7b18a07b22ac4235b95745eccba49 100644 (file)
@@ -2168,6 +2168,7 @@ PHP_FUNCTION(substr_replace)
        }
 
        if (argc > 3) {
+               SEPARATE_ZVAL(len);
                if (Z_TYPE_PP(len) != IS_ARRAY) {
                        convert_to_long_ex(len);
                        l = Z_LVAL_PP(len);
diff --git a/ext/standard/tests/strings/bug42208.phpt b/ext/standard/tests/strings/bug42208.phpt
new file mode 100644 (file)
index 0000000..72488a9
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Bug #42208 (substr_replace() crashes when the same array is passed more than once)
+--FILE--
+<?php
+$a = array(1, 2);
+$c = $a;
+var_dump(substr_replace($a, 1, 1, $c));
+?>
+--EXPECT--
+array(2) {
+  [0]=>
+  string(2) "11"
+  [1]=>
+  string(2) "21"
+}