summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2016-05-06 10:53:25 +0800
committerXinchen Hui <laruence@gmail.com>2016-05-06 10:53:25 +0800
commit4cd9cf8257e40c9fcf43ae2b69bb7b453fc3f6ea (patch)
treefbf777f027368c9b5984f02cf93d61322d3d603a
parentbac6fdb0c52c924e726c5a78de8858bf27b6586b (diff)
parent080f6b10ecf6af557e8dc1732eb154a916cf6838 (diff)
downloadphp-git-4cd9cf8257e40c9fcf43ae2b69bb7b453fc3f6ea.tar.gz
Merge branch 'PHP-7.0'
* PHP-7.0: Fixed test Revert "Fix bug #72162 (again)"
-rw-r--r--Zend/tests/bug72162.phpt7
-rw-r--r--Zend/zend_builtin_functions.c15
2 files changed, 13 insertions, 9 deletions
diff --git a/Zend/tests/bug72162.phpt b/Zend/tests/bug72162.phpt
index 3cd12dea21..5902c585d8 100644
--- a/Zend/tests/bug72162.phpt
+++ b/Zend/tests/bug72162.phpt
@@ -2,10 +2,9 @@
Bug #72162 (use-after-free - error_reporting)
--FILE--
<?php
-error_reporting(1);
+error_reporting(E_ALL);
$var11 = new StdClass();
$var16 = error_reporting($var11);
?>
-okey
---EXPECT--
-okey
+--EXPECTF--
+Catchable fatal error: Object of class stdClass could not be converted to string in %sbug72162.php on line %d
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 6434049a4f..0af280b97e 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -755,22 +755,23 @@ ZEND_FUNCTION(each)
Return the current error_reporting level, and if an argument was passed - change to the new level */
ZEND_FUNCTION(error_reporting)
{
- zend_long err;
+ zval *err;
int old_error_reporting;
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &err) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &err) == FAILURE) {
return;
}
#else
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
- Z_PARAM_LONG(err)
+ Z_PARAM_ZVAL(err)
ZEND_PARSE_PARAMETERS_END();
#endif
old_error_reporting = EG(error_reporting);
if (ZEND_NUM_ARGS() != 0) {
+ zend_string *new_val = zval_get_string(err);
do {
zend_ini_entry *p = EG(error_reporting_ini_entry);
@@ -796,8 +797,12 @@ ZEND_FUNCTION(error_reporting)
zend_string_release(p->value);
}
- p->value = zend_long_to_str(err);
- EG(error_reporting) = err;
+ p->value = new_val;
+ if (Z_TYPE_P(err) == IS_LONG) {
+ EG(error_reporting) = Z_LVAL_P(err);
+ } else {
+ EG(error_reporting) = atoi(ZSTR_VAL(p->value));
+ }
} while (0);
}