Skip to content

Commit df0c8aa

Browse files
committed
JIT: Fix array clobbering by user error handler
Fixes oss-fuzz #46336
1 parent afd8f84 commit df0c8aa

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
@@ -2548,7 +2548,18 @@ ZEND_VM_HANDLER(23, ZEND_ASSIGN_DIM, VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV, SPEC(O
25482548
ZEND_VM_C_LABEL(try_assign_dim_array):
25492549
SEPARATE_ARRAY(object_ptr);
25502550
if (OP2_TYPE == IS_UNUSED) {
2551-
value = GET_OP_DATA_ZVAL_PTR(BP_VAR_R);
2551+
value = GET_OP_DATA_ZVAL_PTR_UNDEF(BP_VAR_R);
2552+
if (OP_DATA_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
2553+
HashTable *ht = Z_ARRVAL_P(object_ptr);
2554+
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE)) {
2555+
GC_ADDREF(ht);
2556+
}
2557+
value = zval_undefined_cv((opline+1)->op1.var EXECUTE_DATA_CC);
2558+
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && !GC_DELREF(ht)) {
2559+
zend_array_destroy(ht);
2560+
ZEND_VM_C_GOTO(assign_dim_error);
2561+
}
2562+
}
25522563
if (OP_DATA_TYPE == IS_CV || OP_DATA_TYPE == IS_VAR) {
25532564
ZVAL_DEREF(value);
25542565
}

0 commit comments

Comments
 (0)