Skip to content

Commit 9346da8

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Handle throwing destructor in BIND_STATIC
2 parents c8fa477 + ec54ffa commit 9346da8

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

Zend/tests/bind_static_exception.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
BIND_STATIC may destroy a variable with a throwing destructor
3+
--FILE--
4+
<?php
5+
class Test {
6+
function __destruct() {
7+
throw new Exception("Foo");
8+
}
9+
}
10+
try {
11+
$new = new Test;
12+
static $new;
13+
} catch (Exception $e) {
14+
echo $e->getMessage(), "\n";
15+
}
16+
?>
17+
--EXPECT--
18+
Foo

Zend/zend_vm_def.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8708,9 +8708,9 @@ ZEND_VM_HANDLER(183, ZEND_BIND_STATIC, CV, UNUSED, REF)
87088708

87098709
value = (zval*)((char*)ht->arData + (opline->extended_value & ~(ZEND_BIND_REF|ZEND_BIND_IMPLICIT|ZEND_BIND_EXPLICIT)));
87108710

8711+
SAVE_OPLINE();
87118712
if (opline->extended_value & ZEND_BIND_REF) {
87128713
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
8713-
SAVE_OPLINE();
87148714
if (UNEXPECTED(zval_update_constant_ex(value, EX(func)->op_array.scope) != SUCCESS)) {
87158715
HANDLE_EXCEPTION();
87168716
}
@@ -8735,7 +8735,7 @@ ZEND_VM_HANDLER(183, ZEND_BIND_STATIC, CV, UNUSED, REF)
87358735
ZVAL_COPY(variable_ptr, value);
87368736
}
87378737

8738-
ZEND_VM_NEXT_OPCODE();
8738+
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
87398739
}
87408740

87418741
ZEND_VM_HOT_HANDLER(184, ZEND_FETCH_THIS, UNUSED, UNUSED)

Zend/zend_vm_execute.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47303,9 +47303,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BIND_STATIC_SPEC_CV_UNUSED_HAN
4730347303

4730447304
value = (zval*)((char*)ht->arData + (opline->extended_value & ~(ZEND_BIND_REF|ZEND_BIND_IMPLICIT|ZEND_BIND_EXPLICIT)));
4730547305

47306+
SAVE_OPLINE();
4730647307
if (opline->extended_value & ZEND_BIND_REF) {
4730747308
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
47308-
SAVE_OPLINE();
4730947309
if (UNEXPECTED(zval_update_constant_ex(value, EX(func)->op_array.scope) != SUCCESS)) {
4731047310
HANDLE_EXCEPTION();
4731147311
}
@@ -47330,7 +47330,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BIND_STATIC_SPEC_CV_UNUSED_HAN
4733047330
ZVAL_COPY(variable_ptr, value);
4733147331
}
4733247332

47333-
ZEND_VM_NEXT_OPCODE();
47333+
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4733447334
}
4733547335

4733647336
static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CHECK_VAR_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)

0 commit comments

Comments
 (0)