Skip to content

Commit fce8061

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #79919: Stack use-after-scope in define()
2 parents 4b84a1f + 1e0bc6e commit fce8061

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PHP NEWS
88
. Fixed bug #79806 (realpath() erroneously resolves link to link). (cmb)
99
. Fixed bug #79895 (PHP_CHECK_GCC_ARG does not allow flags with equal sign).
1010
(Santiago M. Mola)
11+
. Fixed bug #79919 (Stack use-after-scope in define()). (cmb)
1112

1213
- LDAP:
1314
. Fixed memory leaks. (ptomulik)

Zend/tests/bug79919.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #79919 (Stack use-after-scope in define())
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('simplexml')) die('skip simplexml extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$b = error_log(0);
10+
$b = simplexml_load_string('<xml/>', null, $b);
11+
define(0, $b);
12+
?>
13+
--EXPECT--
14+
0

Zend/zend_builtin_functions.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,9 +895,7 @@ ZEND_FUNCTION(define)
895895
case IS_OBJECT:
896896
if (Z_TYPE(val_free) == IS_UNDEF) {
897897
if (Z_OBJ_HT_P(val)->get) {
898-
zval rv;
899-
val = Z_OBJ_HT_P(val)->get(val, &rv);
900-
ZVAL_COPY_VALUE(&val_free, val);
898+
val = Z_OBJ_HT_P(val)->get(val, &val_free);
901899
goto repeat;
902900
} else if (Z_OBJ_HT_P(val)->cast_object) {
903901
if (Z_OBJ_HT_P(val)->cast_object(val, &val_free, IS_STRING) == SUCCESS) {

0 commit comments

Comments
 (0)