Fix use-after-free when trying to write to closure property

This commit is contained in:
Nikita Popov 2019-12-18 10:24:02 +01:00
parent ee89e73312
commit b965f158ac
2 changed files with 23 additions and 1 deletions

View file

@ -0,0 +1,22 @@
--TEST--
Cannot write to closure properties
--FILE--
<?php
class A {
function getFn() {
return function() {
};
}
}
$a = new A;
try {
$c = $a->getFn()->b = new stdClass;
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Closure object cannot have properties

View file

@ -435,7 +435,7 @@ static ZEND_COLD zval *zend_closure_read_property(zval *object, zval *member, in
static ZEND_COLD zval *zend_closure_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */
{
ZEND_CLOSURE_PROPERTY_ERROR();
return value;
return &EG(error_zval);
}
/* }}} */