]> granicus.if.org Git - php/commit
Fix crash when last yielded value is a closure
authorNikita Popov <nikic@php.net>
Fri, 21 Dec 2012 16:28:20 +0000 (17:28 +0100)
committerNikita Popov <nikic@php.net>
Fri, 21 Dec 2012 16:28:20 +0000 (17:28 +0100)
commit14f133036cfa6c2ab3f5eb9af3a0c0b29ed5d554
tree93465630e33919888323fd1f172f24bf5dc7830f
parentffb848b275a085917413c171a79cbfdb1d0159d2
Fix crash when last yielded value is a closure

If zend_generator_close is called from within zend_generator_resume (e.g.
due to a return statement) then all the EGs will still be using the values
from the generator. That's why the stack frame has to be the last thing
that is dtored, otherwise some other dtor that is using
EG(current_execute_data) might access the already freed memory segment.
This was the case with the closure dtor.

The fix is to move the dtors for key and value to the start of the handler.
This way the stack frame is the last thing that is freed.
Zend/tests/generators/yield_closure.phpt [new file with mode: 0644]
Zend/zend_generators.c