com php-src: Fix segfault in method test: Zend/zend_vm_def .h Zend/zend_vm_execute.h

From: Date: Fri, 22 Jun 2012 22:03:28 +0000
Subject: com php-src: Fix segfault in method test: Zend/zend_vm_def .h Zend/zend_vm_execute.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-70048@lists.php.net to get a copy of this message
Commit: 1d3f37ddedc931d700a4e1135f63e094df88dbc4 Author: Nikita Popov <nikic@php.net> Sat, 23 Jun 2012 00:03:28 +0200 Parents: 6233408a2a51389a2bbd250c5900d395648e897f Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1d3f37ddedc931d700a4e1135f63e094df88dbc4 Log: Fix segfault in method test A ref has to be added to $this if the generator is called !nested (which is the case when it is invoked via getIterator). Changed paths: M Zend/zend_vm_def.h M Zend/zend_vm_execute.h Diff: diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index fea1f40..cb24eb9 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -5234,10 +5234,15 @@ ZEND_VM_HANDLER(159, ZEND_SUSPEND_AND_RETURN_GENERATOR, ANY, ANY) /* back up some executor globals */ SAVE_OPLINE(); - EX(current_this) = EG(This); + EX(current_scope) = EG(scope); EX(current_called_scope) = EG(called_scope); + if (EG(This)) { + Z_ADDREF_P(EG(This)); + } + EX(current_this) = EG(This); + /* back up the execution context */ generator = (zend_generator *) zend_object_store_get_object(return_value TSRMLS_CC); generator->execute_data = execute_data; @@ -5278,6 +5283,13 @@ ZEND_VM_HANDLER(159, ZEND_SUSPEND_AND_RETURN_GENERATOR, ANY, ANY) ZEND_VM_RETURN(); } + /* Free $this and stack arguments */ + if (EG(This)) { + zval_ptr_dtor(&EG(This)); + } + + zend_vm_stack_clear_multiple(TSRMLS_C); + /* Bring back the previous execution context */ execute_data = EG(current_execute_data); @@ -5295,8 +5307,6 @@ ZEND_VM_HANDLER(159, ZEND_SUSPEND_AND_RETURN_GENERATOR, ANY, ANY) EX(object) = EX(current_object); EX(called_scope) = DECODE_CTOR(EX(called_scope)); - zend_vm_stack_clear_multiple(TSRMLS_C); - LOAD_REGS(); LOAD_OPLINE(); ZEND_VM_INC_OPCODE(); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 0f965c5..3bf89d3 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1217,10 +1217,15 @@ static int ZEND_FASTCALL ZEND_SUSPEND_AND_RETURN_GENERATOR_SPEC_HANDLER(ZEND_OP /* back up some executor globals */ SAVE_OPLINE(); - EX(current_this) = EG(This); + EX(current_scope) = EG(scope); EX(current_called_scope) = EG(called_scope); + if (EG(This)) { + Z_ADDREF_P(EG(This)); + } + EX(current_this) = EG(This); + /* back up the execution context */ generator = (zend_generator *) zend_object_store_get_object(return_value TSRMLS_CC); generator->execute_data = execute_data; @@ -1261,6 +1266,13 @@ static int ZEND_FASTCALL ZEND_SUSPEND_AND_RETURN_GENERATOR_SPEC_HANDLER(ZEND_OP ZEND_VM_RETURN(); } + /* Free $this and stack arguments */ + if (EG(This)) { + zval_ptr_dtor(&EG(This)); + } + + zend_vm_stack_clear_multiple(TSRMLS_C); + /* Bring back the previous execution context */ execute_data = EG(current_execute_data); @@ -1278,8 +1290,6 @@ static int ZEND_FASTCALL ZEND_SUSPEND_AND_RETURN_GENERATOR_SPEC_HANDLER(ZEND_OP EX(object) = EX(current_object); EX(called_scope) = DECODE_CTOR(EX(called_scope)); - zend_vm_stack_clear_multiple(TSRMLS_C); - LOAD_REGS(); LOAD_OPLINE(); ZEND_VM_INC_OPCODE();

« previous php.cvs (#70048) next »