mirror of
https://github.com/php/php-src.git
synced 2024-11-30 21:35:36 +08:00
Don't allow dynamic properties on generators
Noticed this because we leak those properties in GC. This was never intended to be allowed.
This commit is contained in:
parent
628db3f3b5
commit
174dadf6b4
19
Zend/tests/generators/dynamic_properties.phpt
Normal file
19
Zend/tests/generators/dynamic_properties.phpt
Normal file
@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
It's not possible to assign dynamic properties on a generator
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function gen() {
|
||||
yield;
|
||||
}
|
||||
|
||||
$gen = gen();
|
||||
try {
|
||||
$gen->prop = 42;
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Cannot create dynamic property Generator::$prop
|
@ -1159,7 +1159,7 @@ void zend_register_generator_ce(void) /* {{{ */
|
||||
|
||||
INIT_CLASS_ENTRY(ce, "Generator", class_Generator_methods);
|
||||
zend_ce_generator = zend_register_internal_class(&ce);
|
||||
zend_ce_generator->ce_flags |= ZEND_ACC_FINAL;
|
||||
zend_ce_generator->ce_flags |= ZEND_ACC_FINAL | ZEND_ACC_NO_DYNAMIC_PROPERTIES;
|
||||
zend_ce_generator->create_object = zend_generator_create;
|
||||
zend_ce_generator->serialize = zend_class_serialize_deny;
|
||||
zend_ce_generator->unserialize = zend_class_unserialize_deny;
|
||||
|
Loading…
Reference in New Issue
Block a user