Skip to content

Commit 9191862

Browse files
committed
Fixed bug #72162 (use-after-free - error_reporting)
1 parent 0691e7a commit 9191862

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PHP NEWS
33
?? ??? 2016 PHP 7.0.7
44

55
- Core:
6+
. Fixed bug #72162 (use-after-free - error_reporting). (Laruence)
67
. Add compiler option to disable special case function calls. (Joe)
78
. Fixed bug #72101 (crash on complex code). (Dmitry)
89
. Fixed bug #72100 (implode() inserts garbage into resulting string when

Zend/tests/bug72162.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #72162 (use-after-free - error_reporting)
3+
--FILE--
4+
<?php
5+
error_reporting(1);
6+
$var11 = new StdClass();
7+
$var16 = error_reporting($var11);
8+
?>
9+
okey
10+
--EXPECT--
11+
okey

Zend/zend_builtin_functions.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,8 @@ ZEND_FUNCTION(error_reporting)
704704
#endif
705705

706706
old_error_reporting = EG(error_reporting);
707-
if(ZEND_NUM_ARGS() != 0) {
707+
if (ZEND_NUM_ARGS() != 0) {
708+
zend_string *new_val = zval_get_string(err);
708709
do {
709710
zend_ini_entry *p = EG(error_reporting_ini_entry);
710711

@@ -730,7 +731,7 @@ ZEND_FUNCTION(error_reporting)
730731
zend_string_release(p->value);
731732
}
732733

733-
p->value = zval_get_string(err);
734+
p->value = new_val;
734735
if (Z_TYPE_P(err) == IS_LONG) {
735736
EG(error_reporting) = Z_LVAL_P(err);
736737
} else {

0 commit comments

Comments
 (0)