summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2005-05-04 08:45:46 +0000
committerDmitry Stogov <dmitry@php.net>2005-05-04 08:45:46 +0000
commit37d16df05ceefaa519ca673c36a5e8d8f28e6169 (patch)
tree149e82d8792b6943279003d59509976ac662e84d /Zend
parent95629a63df9dcfa132a49cc150b69b109a93d84e (diff)
downloadphp-git-37d16df05ceefaa519ca673c36a5e8d8f28e6169.tar.gz
Fixed bug #30162 (Catching exception in constructor couses lose of $this)
Diffstat (limited to 'Zend')
-rwxr-xr-xZend/tests/bug30161.phpt3
-rw-r--r--Zend/zend_vm_def.h6
-rw-r--r--Zend/zend_vm_execute.h12
3 files changed, 14 insertions, 7 deletions
diff --git a/Zend/tests/bug30161.phpt b/Zend/tests/bug30161.phpt
index 038a151e0e..22f8fb59e8 100755
--- a/Zend/tests/bug30161.phpt
+++ b/Zend/tests/bug30161.phpt
@@ -20,7 +20,7 @@ class hariCow extends FIIFO {
}
public function __toString() {
- return "Rusticus in asino sedet.";
+ return "ok\n";
}
}
@@ -31,3 +31,4 @@ $db = new hariCow;
echo $db;
?>
--EXPECT--
+ok
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index e4774a8ee0..8aca967119 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -1890,9 +1890,11 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
if (EG(exception) && EX(fbc) && EX(fbc)->common.fn_flags&ZEND_ACC_CTOR) {
EG(This)->refcount--;
if (EG(This)->refcount == 1) {
- zend_object_store_ctor_failed(EG(This) TSRMLS_CC);
+ zend_object_store_ctor_failed(EG(This) TSRMLS_CC);
+ }
+ if (should_change_scope && EG(This) != current_this) {
+ zval_ptr_dtor(&EG(This));
}
- zval_ptr_dtor(&EG(This));
} else if (should_change_scope) {
zval_ptr_dtor(&EG(This));
}
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 174f577000..cdbe7596b4 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -254,9 +254,11 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
if (EG(exception) && EX(fbc) && EX(fbc)->common.fn_flags&ZEND_ACC_CTOR) {
EG(This)->refcount--;
if (EG(This)->refcount == 1) {
- zend_object_store_ctor_failed(EG(This) TSRMLS_CC);
+ zend_object_store_ctor_failed(EG(This) TSRMLS_CC);
+ }
+ if (should_change_scope && EG(This) != current_this) {
+ zval_ptr_dtor(&EG(This));
}
- zval_ptr_dtor(&EG(This));
} else if (should_change_scope) {
zval_ptr_dtor(&EG(This));
}
@@ -30823,9 +30825,11 @@ static int zend_do_fcall_common_helper(ZEND_OPCODE_HANDLER_ARGS)
if (EG(exception) && EX(fbc) && EX(fbc)->common.fn_flags&ZEND_ACC_CTOR) {
EG(This)->refcount--;
if (EG(This)->refcount == 1) {
- zend_object_store_ctor_failed(EG(This) TSRMLS_CC);
+ zend_object_store_ctor_failed(EG(This) TSRMLS_CC);
+ }
+ if (should_change_scope && EG(This) != current_this) {
+ zval_ptr_dtor(&EG(This));
}
- zval_ptr_dtor(&EG(This));
} else if (should_change_scope) {
zval_ptr_dtor(&EG(This));
}