Skip to content

Commit 9042c7a

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Handle undef value in assign_dim jit
2 parents 971142a + e766378 commit 9042c7a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,13 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_obj_rw_helper(zval *object_ptr, zva
11231123

11241124
static void ZEND_FASTCALL zend_jit_assign_dim_helper(zval *object_ptr, zval *dim, zval *value, zval *result)
11251125
{
1126+
if (UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
1127+
const zend_op *op_data = EG(current_execute_data)->opline + 1;
1128+
ZEND_ASSERT(op_data->opcode == ZEND_OP_DATA && op_data->op1_type == IS_CV);
1129+
zend_jit_undefined_op_helper(op_data->op1.var);
1130+
value = &EG(uninitialized_zval);
1131+
}
1132+
11261133
if (EXPECTED(Z_TYPE_P(object_ptr) == IS_OBJECT)) {
11271134
ZVAL_DEREF(value);
11281135
Z_OBJ_HT_P(object_ptr)->write_dimension(Z_OBJ_P(object_ptr), dim, value);

ext/opcache/tests/jit/assign_dim_002.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ try {
120120
echo $e->getMessage(), "\n";
121121
}
122122

123+
function array_access_undef() {
124+
$ao = new ArrayObject;
125+
$ao[0] = $undef;
126+
var_dump($ao[0]);
127+
}
128+
129+
array_access_undef();
123130
?>
124131
--EXPECTF--
125132
array(1) {
@@ -215,3 +222,6 @@ array(1) {
215222

216223
Deprecated: Automatic conversion of false to array is deprecated in %s on line %d
217224
Illegal offset type
225+
226+
Warning: Undefined variable $undef in %s on line %d
227+
NULL

0 commit comments

Comments
 (0)