Skip to content

Commit 1b7d50b

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: JIT: Fix array separation after capturing by user error handler
2 parents 491793a + c958ab1 commit 1b7d50b

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,8 @@ static zend_always_inline void ZEND_FASTCALL zend_jit_fetch_dim_obj_helper(zval
14131413
ZVAL_NULL(result);
14141414
return;
14151415
}
1416+
SEPARATE_ARRAY(object_ptr);
1417+
arr = Z_ARRVAL_P(object_ptr);
14161418
zval *var;
14171419
if (dim) {
14181420
if (type == BP_VAR_W) {
@@ -1517,6 +1519,8 @@ static void ZEND_FASTCALL zend_jit_assign_dim_helper(zval *object_ptr, zval *dim
15171519
}
15181520
return;
15191521
}
1522+
SEPARATE_ARRAY(object_ptr);
1523+
arr = Z_ARRVAL_P(object_ptr);
15201524
zval *var = dim
15211525
? zend_jit_fetch_dim_w_helper(arr, dim)
15221526
: zend_hash_next_index_insert_new(arr, &EG(uninitialized_zval));
@@ -1595,6 +1599,8 @@ static void ZEND_FASTCALL zend_jit_assign_dim_op_helper(zval *container, zval *d
15951599
zend_array_destroy(arr);
15961600
return;
15971601
}
1602+
SEPARATE_ARRAY(container);
1603+
arr = Z_ARRVAL_P(container);
15981604
zval *var = dim
15991605
? zend_jit_fetch_dim_rw_helper(arr, dim)
16001606
: zend_hash_next_index_insert_new(arr, &EG(uninitialized_zval));
@@ -2366,9 +2372,11 @@ static zval * ZEND_FASTCALL zend_jit_prepare_assign_dim_ref(zval *ref) {
23662372
return NULL;
23672373
}
23682374
if (Z_TYPE_P(val) == IS_FALSE) {
2375+
ZVAL_ARR(val, zend_new_array(8));
23692376
zend_false_to_array_deprecated();
2377+
} else {
2378+
ZVAL_ARR(val, zend_new_array(8));
23702379
}
2371-
ZVAL_ARR(val, zend_new_array(8));
23722380
}
23732381
return val;
23742382
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
JIT ASSIGN_DIM: 007
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
set_error_handler(function() {
11+
$GLOBALS['x'] = $GLOBALS['y'];
12+
});
13+
14+
function x(&$s) {
15+
$s[0] = 1;
16+
};
17+
$y = false;
18+
x($y);
19+
var_dump($x,$y);
20+
?>
21+
--EXPECT--
22+
array(0) {
23+
}
24+
array(1) {
25+
[0]=>
26+
int(1)
27+
}

0 commit comments

Comments
 (0)