]> granicus.if.org Git - php/commitdiff
Fixed a possible memory corruption in substr_replace()
authorDmitry Stogov <dmitry@php.net>
Tue, 11 May 2010 11:59:13 +0000 (11:59 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 11 May 2010 11:59:13 +0000 (11:59 +0000)
ext/standard/string.c

index 1ffbaa9663a2f15caad12a52d75e28d1558fecb2..250af0702eebd29e0a0050c352a88aaf40949f54 100644 (file)
@@ -2219,12 +2219,21 @@ PHP_FUNCTION(substr_replace)
        }
        
        if (Z_TYPE_PP(str) != IS_ARRAY) {
+               if (Z_ISREF_PP(str)) {
+                       SEPARATE_ZVAL(str);
+               }
                convert_to_string_ex(str);
        }
        if (Z_TYPE_PP(repl) != IS_ARRAY) {
+               if (Z_ISREF_PP(repl)) {
+                       SEPARATE_ZVAL(repl);
+               }
                convert_to_string_ex(repl);
        }
        if (Z_TYPE_PP(from) != IS_ARRAY) {
+               if (Z_ISREF_PP(from)) {
+                       SEPARATE_ZVAL(from);
+               }
                convert_to_long_ex(from);
        }