]> granicus.if.org Git - php/commitdiff
Fixed bug #73067 (__debugInfo crashes when throwing an exception)
authorXinchen Hui <laruence@gmail.com>
Tue, 13 Sep 2016 02:58:57 +0000 (10:58 +0800)
committerXinchen Hui <laruence@gmail.com>
Tue, 13 Sep 2016 02:58:57 +0000 (10:58 +0800)
NEWS
Zend/tests/bug73067.phpt [new file with mode: 0644]
Zend/zend_object_handlers.c

diff --git a/NEWS b/NEWS
index efae2e4b27d9f31c555b22e28bb84d331916f12d..1e2d599232e7ec9e230d1c7448fe77c34ddc096d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP                                                                        NEWS
 ?? ??? 2016 PHP 7.0.12
 
 - Core:
+  . Fixed bug #73067 (__debugInfo crashes when throwing an exception).
+    (Laruence)
   . Fixed bug #73025 (Heap Buffer Overflow in virtual_popen of
     zend_virtual_cwd.c). (cmb)
   . Fixed bug #72703 (Out of bounds global memory read in BF_crypt triggered by
diff --git a/Zend/tests/bug73067.phpt b/Zend/tests/bug73067.phpt
new file mode 100644 (file)
index 0000000..f5d34a8
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Bug #73067 (__debugInfo crashes when throwing an exception)
+--FILE--
+<?php
+
+class Debug
+{
+       public function __debugInfo()
+       {
+               throw new Exception("Test Crash");
+       }
+}
+
+try {
+       var_dump(new Debug());
+} catch (Exception $e) {
+       echo $e->getMessage();
+}
+?>
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %sbug73067.php on line %d
index 70dab660b3c4fa34451b33a6bf81b456c4817b11..39c4d3d7e8220de09b9327a9c084277f9d47ad31 100644 (file)
@@ -182,6 +182,7 @@ ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp) /* {{{ *
                return ht;
        }
 
+       zend_clear_exception();
        zend_error_noreturn(E_ERROR, ZEND_DEBUGINFO_FUNC_NAME "() must return an array");
 
        return NULL; /* Compilers are dumb and don't understand that noreturn means that the function does NOT need a return value... */