Skip to content

Commit 2fddc4a

Browse files
committed
Fixed bug #73900
1 parent de66e80 commit 2fddc4a

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ PHP NEWS
66
. Fixed bug #74780 (parse_url() borken when query string contains colon).
77
(jhdxr)
88
. Fixed bug #74761 (Unary operator expected error on some systems). (petk)
9+
. Fixed bug #73900 (Use After Free in unserialize() SplFixedArray). (nikic)
910

1011
- SPL:
1112
. Fixed bug #73471 (PHP freezes with AppendIterator). (jhdxr)

Zend/tests/bug73900.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #73900: Use After Free in unserialize() SplFixedArray
3+
--FILE--
4+
<?php
5+
6+
$a = new stdClass;
7+
$b = new SplFixedArray(1);
8+
$b[0] = $a;
9+
$c = &$b[0];
10+
var_dump($c);
11+
12+
?>
13+
--EXPECT--
14+
object(stdClass)#1 (0) {
15+
}

Zend/zend_execute.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,16 +1758,9 @@ static zend_always_inline void zend_fetch_dimension_address(zval *result, zval *
17581758
zend_error(E_NOTICE, "Indirect modification of overloaded element of %s has no effect", ZSTR_VAL(ce->name));
17591759
} else if (EXPECTED(retval && Z_TYPE_P(retval) != IS_UNDEF)) {
17601760
if (!Z_ISREF_P(retval)) {
1761-
if (Z_REFCOUNTED_P(retval) &&
1762-
Z_REFCOUNT_P(retval) > 1) {
1763-
if (Z_TYPE_P(retval) != IS_OBJECT) {
1764-
Z_DELREF_P(retval);
1765-
ZVAL_DUP(result, retval);
1766-
retval = result;
1767-
} else {
1768-
ZVAL_COPY_VALUE(result, retval);
1769-
retval = result;
1770-
}
1761+
if (result != retval) {
1762+
ZVAL_COPY(result, retval);
1763+
retval = result;
17711764
}
17721765
if (Z_TYPE_P(retval) != IS_OBJECT) {
17731766
zend_class_entry *ce = Z_OBJCE_P(container);

0 commit comments

Comments
 (0)