Skip to content

Commit cb81406

Browse files
committed
Simply increment/decrement check
1 parent f4eea7c commit cb81406

File tree

3 files changed

+14
-144
lines changed

3 files changed

+14
-144
lines changed

Zend/zend_execute.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,6 +2991,11 @@ static zend_never_inline void zend_fetch_object_dimension_address(zval *result,
29912991
offset++;
29922992
}
29932993

2994+
if (UNEXPECTED(opline->extended_value == ZEND_FETCH_DIM_INCDEC)) {
2995+
zend_throw_error(NULL, "Cannot increment/decrement object offsets");
2996+
ZVAL_UNDEF(result);
2997+
goto clean_up;
2998+
}
29942999
if (EXPECTED(obj->ce->dimension_handlers)) {
29953000
if (EXPECTED(offset && obj->ce->dimension_handlers->fetch_dimension)) {
29963001
ZEND_ASSERT(zend_check_dimension_interfaces_implemented(obj, /* has_offset */ true, BP_VAR_FETCH));

Zend/zend_vm_def.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,22 +1956,7 @@ ZEND_VM_HANDLER(87, ZEND_FETCH_DIM_RW, VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV)
19561956

19571957
SAVE_OPLINE();
19581958
container = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
1959-
if (UNEXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
1960-
const zend_op *next_opline = OPLINE + 1;
1961-
if (UNEXPECTED(
1962-
next_opline->opcode == ZEND_PRE_INC
1963-
|| next_opline->opcode == ZEND_PRE_DEC
1964-
|| next_opline->opcode == ZEND_POST_INC
1965-
|| next_opline->opcode == ZEND_POST_DEC
1966-
)) {
1967-
zend_throw_error(NULL, "Cannot increment/decrement object offsets");
1968-
ZVAL_UNDEF(EX_VAR(opline->result.var));
1969-
} else {
1970-
zend_fetch_dimension_address_RW(container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE OPLINE_CC EXECUTE_DATA_CC);
1971-
}
1972-
} else {
1973-
zend_fetch_dimension_address_RW(container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE OPLINE_CC EXECUTE_DATA_CC);
1974-
}
1959+
zend_fetch_dimension_address_RW(container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE OPLINE_CC EXECUTE_DATA_CC);
19751960

19761961
FREE_OP2();
19771962
if (OP1_TYPE == IS_VAR) {

Zend/zend_vm_execute.h

Lines changed: 8 additions & 128 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)