]> granicus.if.org Git - php/commitdiff
fix #40815 (using strings like "class::func" and static methods in set_exception_hand...
authorAntony Dovgal <tony2001@php.net>
Thu, 15 Mar 2007 16:44:12 +0000 (16:44 +0000)
committerAntony Dovgal <tony2001@php.net>
Thu, 15 Mar 2007 16:44:12 +0000 (16:44 +0000)
Zend/tests/bug40815.phpt [new file with mode: 0644]
Zend/zend.c
Zend/zend_execute_API.c

diff --git a/Zend/tests/bug40815.phpt b/Zend/tests/bug40815.phpt
new file mode 100644 (file)
index 0000000..6f7477a
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Bug #40815 (using strings like "class::func" and static methods in set_exception_handler() might result in crash).
+--FILE--
+<?php
+
+class ehandle{
+       static public function exh ($ex) {
+               echo 'foo';
+       }
+}
+
+set_exception_handler("ehandle::exh");
+
+throw new Exception ("Whiii");
+echo "Done\n";
+?>
+--EXPECTF--    
+foo
index 87342e2a466f58764a52d670f4a5e72a475622da..88601eab4ea7c2bb07061572298500caa654a85b 100644 (file)
@@ -1146,6 +1146,9 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
                                                        zval_ptr_dtor(&retval2);
                                                }
                                        } else {
+                                               if (!EG(exception)) {
+                                                       EG(exception) = old_exception;
+                                               }
                                                zend_exception_error(EG(exception) TSRMLS_CC);
                                        }
                                        efree(params);
index 95efb309e8cd4c8c9e68c4f625c07de35754a223..2fb02c421a88308d2b618efc03354bd77832479d 100644 (file)
@@ -750,7 +750,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
 
                fname = Z_STRVAL_P(fci->function_name);
                fname_len = Z_STRLEN_P(fci->function_name);
-               if (calling_scope && (colon = strstr(fname, "::")) != NULL) {
+               if ((colon = strstr(fname, "::")) != NULL) {
                        int clen = colon - fname;
                        int mlen = fname_len - clen - 2;
                        zend_class_entry **pce, *ce_child = NULL;