com php-src: Fixed bug #74408 (Endless loop bypassing execution time limit): NEWS Zend/tests/bug74408.phpt Zend/zend_execute_API .c

[email protected] (Xinchen Hui)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    eb03f16442c7ee10842dde0140b933d2be60b84b
Author:    Xinchen Hui <[email protected]>         Tue, 11 Apr 2017 18:46:16 +0800
Parents:   dd17659b869e44a589edc5a26e0f0bcc869597f2
Branches:  PHP-7.0 PHP-7.1 master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=eb03f16442c7ee10842dde0140b933d2be60b84b

Log:
Fixed bug #74408 (Endless loop bypassing execution time limit)

Bugs:
https://bugs.php.net/74408

Changed paths:
  M  NEWS
  A  Zend/tests/bug74408.phpt
  M  Zend/zend_execute_API.c


Diff:
diff --git a/NEWS b/NEWS
index dd25136..889fd1d 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2017 PHP 7.0.19
 
+- Core:
+  . Fixed bug #74408 (Endless loop bypassing execution time limit). (Laruence)
+
 - Date:
   . Fixed bug #74404 (Wrong reflection on DateTimeZone::getTransitions).
     (krakjoe)
diff --git a/Zend/tests/bug74408.phpt b/Zend/tests/bug74408.phpt
new file mode 100644
index 0000000..c0cf2f8
--- /dev/null
+++ b/Zend/tests/bug74408.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Bug #74408 (Endless loop bypassing execution time limit)
+--INI--
+error_reporting = E_ALL | E_DEPRECATED | E_STRICT
+--FILE--
+<?php
+
+ //php.ini: error_reporting = E_ALL | E_DEPRECATED | E_STRICT
+
+ class ErrorHandling {
+
+  public  function error_handler($errno, $errstr, $errfile, $errline) {
+	  $bla = new NonExistingClass2();
+  }
+
+  public function exception_handler(Error $e) { 
+	  echo "Caught, exception: " . $e->getMessage();
+  }
+ }
+
+ set_error_handler('ErrorHandling::error_handler');
+ set_exception_handler('ErrorHandling::exception_handler');
+
+ $blubb = new NonExistingClass();
+?>
+--EXPECTF--
+Deprecated: Non-static method ErrorHandling::error_handler() should not be called statically in %sbug74408.php on line %d
+
+Deprecated: Non-static method ErrorHandling::error_handler() should not be called statically in %sbug74408.php on line %d
+
+Deprecated: Non-static method ErrorHandling::error_handler() should not be called statically in Unknown on line 0
+
+Fatal error: Uncaught Error: Class 'NonExistingClass2' not found in %sbug74408.php:%d
+Stack trace:
+#0 [internal function]: ErrorHandling::error_handler(8192, 'Non-static meth...', '%s', %d, Array)
+#1 %sbug74408.php(%d): set_exception_handler('ErrorHandling::...')
+#2 {main}
+  thrown in %sbug74408.php on line %d
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 28a75b7..ff2d22f 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -755,6 +755,15 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
 			}
 			zend_error(E_DEPRECATED, "%s", error);
 			efree(error);
+			if (UNEXPECTED(EG(exception))) {
+				if (callable_name) {
+					zend_string_release(callable_name);
+				}
+				if (EG(current_execute_data) == &dummy_execute_data) {
+					EG(current_execute_data) = dummy_execute_data.prev_execute_data;
+				}
+				return FAILURE;
+			}
 		}
 		zend_string_release(callable_name);
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.