Skip to content

Commit 247105a

Browse files
committed
Property handle read_property exception in fetch_property_address
Otherwise we leak (and corrupt uninitialized_zval).
1 parent 8e2f219 commit 247105a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Exception thrown by __get() during =& assignment
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
private $x;
8+
public function &__get($name) {
9+
throw new Exception("Foobar");
10+
}
11+
}
12+
13+
$test = new Test;
14+
$y = 5;
15+
try {
16+
$test->x =& $y;
17+
} catch (Exception $e) {
18+
echo $e->getMessage(), "\n";
19+
}
20+
21+
?>
22+
--EXPECT--
23+
Foobar

Zend/zend_execute.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,6 +2872,10 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
28722872
}
28732873
return;
28742874
}
2875+
if (UNEXPECTED(EG(exception))) {
2876+
ZVAL_ERROR(result);
2877+
return;
2878+
}
28752879
} else if (UNEXPECTED(Z_ISERROR_P(ptr))) {
28762880
ZVAL_ERROR(result);
28772881
return;

0 commit comments

Comments
 (0)