Skip to content

Commit 4f18dbe

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: JIT: Fix array clobbering by user error handler
2 parents e721a42 + c489e36 commit 4f18dbe

File tree

3 files changed

+391
-9
lines changed

3 files changed

+391
-9
lines changed

Zend/zend_vm_def.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2541,7 +2541,18 @@ ZEND_VM_HANDLER(23, ZEND_ASSIGN_DIM, VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV, SPEC(O
25412541
ZEND_VM_C_LABEL(try_assign_dim_array):
25422542
SEPARATE_ARRAY(object_ptr);
25432543
if (OP2_TYPE == IS_UNUSED) {
2544-
value = GET_OP_DATA_ZVAL_PTR(BP_VAR_R);
2544+
value = GET_OP_DATA_ZVAL_PTR_UNDEF(BP_VAR_R);
2545+
if (OP_DATA_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
2546+
HashTable *ht = Z_ARRVAL_P(object_ptr);
2547+
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE)) {
2548+
GC_ADDREF(ht);
2549+
}
2550+
value = zval_undefined_cv((opline+1)->op1.var EXECUTE_DATA_CC);
2551+
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && !GC_DELREF(ht)) {
2552+
zend_array_destroy(ht);
2553+
ZEND_VM_C_GOTO(assign_dim_error);
2554+
}
2555+
}
25452556
if (OP_DATA_TYPE == IS_CV || OP_DATA_TYPE == IS_VAR) {
25462557
ZVAL_DEREF(value);
25472558
}

0 commit comments

Comments
 (0)