mirror of
https://github.com/php/php-src.git
synced 2026-04-28 18:53:33 +02:00
Do not add a ref to EX(object) on generator clone
If a ref has to be added it will be already added while walking the call slots.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Cloning a generator after an object method was called
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class A { public function b() { } }
|
||||
|
||||
function gen() {
|
||||
$a = new A;
|
||||
$a->b();
|
||||
yield;
|
||||
}
|
||||
|
||||
$g1 = gen();
|
||||
$g1->rewind();
|
||||
$g2 = clone $g1;
|
||||
|
||||
echo "Done";
|
||||
--EXPECT--
|
||||
Done
|
||||
@@ -223,6 +223,7 @@ static void zend_generator_clone_storage(zend_generator *orig, zend_generator **
|
||||
/* copy */
|
||||
clone->execute_data->opline = execute_data->opline;
|
||||
clone->execute_data->function_state = execute_data->function_state;
|
||||
clone->execute_data->object = execute_data->object;
|
||||
clone->execute_data->current_scope = execute_data->current_scope;
|
||||
clone->execute_data->current_called_scope = execute_data->current_called_scope;
|
||||
clone->execute_data->fast_ret = execute_data->fast_ret;
|
||||
@@ -326,11 +327,6 @@ static void zend_generator_clone_storage(zend_generator *orig, zend_generator **
|
||||
clone->execute_data->current_this = execute_data->current_this;
|
||||
Z_ADDREF_P(execute_data->current_this);
|
||||
}
|
||||
|
||||
if (execute_data->object) {
|
||||
clone->execute_data->object = execute_data->object;
|
||||
Z_ADDREF_P(execute_data->object);
|
||||
}
|
||||
}
|
||||
|
||||
/* The value and key are known not to be references, so simply add refs */
|
||||
|
||||
Reference in New Issue
Block a user