]> granicus.if.org Git - php/commitdiff
Fixed bug #39445 (Calling debug_backtrace() in the __toString() function produces...
authorDmitry Stogov <dmitry@php.net>
Wed, 15 Nov 2006 16:05:11 +0000 (16:05 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 15 Nov 2006 16:05:11 +0000 (16:05 +0000)
NEWS
Zend/tests/bug39445.phpt [new file with mode: 0755]
Zend/zend_builtin_functions.c

diff --git a/NEWS b/NEWS
index e09b5254c360e0b0add71f722057aea3e1121442..9b6f91436ff73e7ac25747062b3ce3e7bec5e5e9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,8 @@ PHP                                                                        NEWS
 - Fixed wrong signature initialization in imagepng (Takeshi Abe)
 - Added optimization for imageline with horizontal and vertial lines (Pierre)
 - Fixed bug #39454 (Returning a SOAP array segfaults PHP). (Dmitry)
+- Fixed bug #39445 (Calling debug_backtrace() in the __toString() function
+  produces a crash). (Dmitry)
 - Fixed bug #39414 (Syntax error while compiling with Sun Workshop Complier).
   (Johannes)
 - Fixed bug #39398 (Booleans are not automatically translated to integers).
diff --git a/Zend/tests/bug39445.phpt b/Zend/tests/bug39445.phpt
new file mode 100755 (executable)
index 0000000..cf1607f
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #39445 (Calling debug_backtrace() in the __toString() function produces a crash)
+--FILE--
+<?php
+class test {
+       public function __toString() {
+               debug_backtrace();
+               return 'lowercase';
+       }
+}
+
+       $test = new test();
+       echo strtoupper($test);
+?>
+--EXPECT--
+LOWERCASE
index 6ae3a0fbd5cd7f9b211cee0161c5f4145e822be1..b623ea5abf0a598f14df75ff5ad64318905ff23d 100644 (file)
@@ -1661,7 +1661,9 @@ static zval *debug_backtrace_get_args(void ***curpos TSRMLS_DC)
        while (--arg_count >= 0) {
                arg = (zval **) p++;
                if (*arg) {
-                       SEPARATE_ZVAL_TO_MAKE_IS_REF(arg);
+                       if ((*arg)->type != IS_OBJECT) {
+                               SEPARATE_ZVAL_TO_MAKE_IS_REF(arg);
+                       }
                        (*arg)->refcount++;
                        add_next_index_zval(arg_array, *arg);
                } else {