mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix use-after-free when trying to write to closure property
This commit is contained in:
parent
ee89e73312
commit
b965f158ac
2 changed files with 23 additions and 1 deletions
22
Zend/tests/closure_write_prop.phpt
Normal file
22
Zend/tests/closure_write_prop.phpt
Normal 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
|
|
@ -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);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue