summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS4
-rw-r--r--Zend/tests/bug73163.phpt22
-rw-r--r--Zend/zend_execute_API.c23
3 files changed, 38 insertions, 11 deletions
diff --git a/NEWS b/NEWS
index d42a9f409f..43e85ac1e3 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2016, PHP 7.1.0RC3
+- Core:
+ . Fixed bug #73163 (PHP hangs if error handler throws while accessing undef
+ const in default value). (Nikita)
+
- COM:
. Fixed bug #73126 (Cannot pass parameter 1 by reference). (Anatol)
. Fixed bug #69579 (Invalid free in extension trait). (John Boehr)
diff --git a/Zend/tests/bug73163.phpt b/Zend/tests/bug73163.phpt
new file mode 100644
index 0000000000..448d7f5959
--- /dev/null
+++ b/Zend/tests/bug73163.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #73163 (PHP hangs if error handler throws while accessing undef const in default value)
+--FILE--
+<?php
+
+function doSomething(string $value = UNDEFINED) {
+}
+
+set_error_handler(function($errno, $errstr) {
+ throw new Exception($errstr);
+});
+
+doSomething();
+
+?>
+--EXPECTF--
+Fatal error: Uncaught Exception: Use of undefined constant UNDEFINED - assumed 'UNDEFINED' in %s:%d
+Stack trace:
+#0 %s(%d): {closure}(%s)
+#1 %s(%d): doSomething()
+#2 {main}
+ thrown in %s on line %d
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index dc411af835..2e299e8515 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -587,8 +587,6 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */
ZVAL_EMPTY_STRING(p);
}
} else if (UNEXPECTED((const_value = zend_get_constant_ex(Z_STR_P(p), scope, Z_CONST_FLAGS_P(p))) == NULL)) {
- char *actual = Z_STRVAL_P(p);
-
if (UNEXPECTED(EG(exception))) {
RESET_CONSTANT_VISITED(p);
return FAILURE;
@@ -603,26 +601,29 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */
return FAILURE;
} else {
zend_string *save = Z_STR_P(p);
+ char *actual = Z_STRVAL_P(p);
size_t actual_len = Z_STRLEN_P(p);
char *slash = (char *) zend_memrchr(actual, '\\', actual_len);
if (slash) {
actual = slash + 1;
actual_len -= (actual - Z_STRVAL_P(p));
- if (inline_change) {
- zend_string *s = zend_string_init(actual, actual_len, 0);
- Z_STR_P(p) = s;
- Z_TYPE_FLAGS_P(p) = IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE;
- }
}
- zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual);
+ zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual);
+ if (EG(exception)) {
+ RESET_CONSTANT_VISITED(p);
+ return FAILURE;
+ }
+
if (!inline_change) {
ZVAL_STRINGL(p, actual, actual_len);
} else {
- Z_TYPE_INFO_P(p) = Z_REFCOUNTED_P(p) ?
- IS_STRING_EX : IS_INTERNED_STRING_EX;
- if (save && ZSTR_VAL(save) != actual) {
+ if (slash) {
+ ZVAL_STRINGL(p, actual, actual_len);
zend_string_release(save);
+ } else {
+ Z_TYPE_INFO_P(p) = Z_REFCOUNTED_P(p) ?
+ IS_STRING_EX : IS_INTERNED_STRING_EX;
}
}
}