1
0
mirror of https://github.com/php/php-src.git synced 2026-04-20 06:21:12 +02:00

Merge branch 'PHP-8.1'

* PHP-8.1:
  Handle throwing destructor in BIND_STATIC
This commit is contained in:
Nikita Popov
2021-09-29 10:17:27 +02:00
3 changed files with 22 additions and 4 deletions

View File

@@ -0,0 +1,18 @@
--TEST--
BIND_STATIC may destroy a variable with a throwing destructor
--FILE--
<?php
class Test {
function __destruct() {
throw new Exception("Foo");
}
}
try {
$new = new Test;
static $new;
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Foo

View File

@@ -8717,9 +8717,9 @@ ZEND_VM_HANDLER(183, ZEND_BIND_STATIC, CV, UNUSED, REF)
value = (zval*)((char*)ht->arData + (opline->extended_value & ~(ZEND_BIND_REF|ZEND_BIND_IMPLICIT|ZEND_BIND_EXPLICIT)));
SAVE_OPLINE();
if (opline->extended_value & ZEND_BIND_REF) {
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
SAVE_OPLINE();
if (UNEXPECTED(zval_update_constant_ex(value, EX(func)->op_array.scope) != SUCCESS)) {
HANDLE_EXCEPTION();
}
@@ -8744,7 +8744,7 @@ ZEND_VM_HANDLER(183, ZEND_BIND_STATIC, CV, UNUSED, REF)
ZVAL_COPY(variable_ptr, value);
}
ZEND_VM_NEXT_OPCODE();
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
ZEND_VM_HOT_HANDLER(184, ZEND_FETCH_THIS, UNUSED, UNUSED)

View File

@@ -47402,9 +47402,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BIND_STATIC_SPEC_CV_UNUSED_HAN
value = (zval*)((char*)ht->arData + (opline->extended_value & ~(ZEND_BIND_REF|ZEND_BIND_IMPLICIT|ZEND_BIND_EXPLICIT)));
SAVE_OPLINE();
if (opline->extended_value & ZEND_BIND_REF) {
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
SAVE_OPLINE();
if (UNEXPECTED(zval_update_constant_ex(value, EX(func)->op_array.scope) != SUCCESS)) {
HANDLE_EXCEPTION();
}
@@ -47429,7 +47429,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BIND_STATIC_SPEC_CV_UNUSED_HAN
ZVAL_COPY(variable_ptr, value);
}
ZEND_VM_NEXT_OPCODE();
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CHECK_VAR_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)