mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.1'
* PHP-8.1: Fix array clobering by user error handler
This commit is contained in:
commit
d9926a109d
6 changed files with 318 additions and 476 deletions
|
@ -1380,9 +1380,9 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_string_offset
|
|||
zend_type_error("Cannot access offset of type %s on string", zend_zval_type_name(offset));
|
||||
}
|
||||
|
||||
static zend_never_inline void zend_assign_to_object_dim(zval *object, zval *dim, zval *value OPLINE_DC EXECUTE_DATA_DC)
|
||||
static zend_never_inline void zend_assign_to_object_dim(zend_object *obj, zval *dim, zval *value OPLINE_DC EXECUTE_DATA_DC)
|
||||
{
|
||||
Z_OBJ_HT_P(object)->write_dimension(Z_OBJ_P(object), dim, value);
|
||||
obj->handlers->write_dimension(obj, dim, value);
|
||||
|
||||
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ZVAL_COPY(EX_VAR(opline->result.var), value);
|
||||
|
@ -1417,6 +1417,7 @@ static zend_never_inline void zend_binary_assign_op_obj_dim(zend_object *obj, zv
|
|||
zval *z;
|
||||
zval rv, res;
|
||||
|
||||
GC_ADDREF(obj);
|
||||
value = get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1);
|
||||
if ((z = obj->handlers->read_dimension(obj, property, BP_VAR_R, &rv)) != NULL) {
|
||||
|
||||
|
@ -1437,6 +1438,9 @@ static zend_never_inline void zend_binary_assign_op_obj_dim(zend_object *obj, zv
|
|||
}
|
||||
}
|
||||
FREE_OP((opline+1)->op1_type, (opline+1)->op1.var);
|
||||
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
|
||||
zend_objects_store_del(obj);
|
||||
}
|
||||
}
|
||||
|
||||
static zend_never_inline void zend_binary_assign_op_typed_ref(zend_reference *ref, zval *value OPLINE_DC EXECUTE_DATA_DC)
|
||||
|
@ -2390,22 +2394,17 @@ fetch_from_array:
|
|||
}
|
||||
ZVAL_UNDEF(result);
|
||||
} else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
|
||||
zend_object *obj = Z_OBJ_P(container);
|
||||
GC_ADDREF(obj);
|
||||
if (ZEND_CONST_COND(dim_type == IS_CV, dim != NULL) && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
|
||||
zend_object *obj = Z_OBJ_P(container);
|
||||
GC_ADDREF(obj);
|
||||
dim = ZVAL_UNDEFINED_OP2();
|
||||
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
|
||||
zend_objects_store_del(obj);
|
||||
ZVAL_NULL(result);
|
||||
return;
|
||||
}
|
||||
} else if (dim_type == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
|
||||
dim++;
|
||||
}
|
||||
retval = Z_OBJ_HT_P(container)->read_dimension(Z_OBJ_P(container), dim, type, result);
|
||||
retval = obj->handlers->read_dimension(obj, dim, type, result);
|
||||
|
||||
if (UNEXPECTED(retval == &EG(uninitialized_zval))) {
|
||||
zend_class_entry *ce = Z_OBJCE_P(container);
|
||||
zend_class_entry *ce = obj->ce;
|
||||
|
||||
ZVAL_NULL(result);
|
||||
zend_error(E_NOTICE, "Indirect modification of overloaded element of %s has no effect", ZSTR_VAL(ce->name));
|
||||
|
@ -2416,7 +2415,7 @@ fetch_from_array:
|
|||
retval = result;
|
||||
}
|
||||
if (Z_TYPE_P(retval) != IS_OBJECT) {
|
||||
zend_class_entry *ce = Z_OBJCE_P(container);
|
||||
zend_class_entry *ce = obj->ce;
|
||||
zend_error(E_NOTICE, "Indirect modification of overloaded element of %s has no effect", ZSTR_VAL(ce->name));
|
||||
}
|
||||
} else if (UNEXPECTED(Z_REFCOUNT_P(retval) == 1)) {
|
||||
|
@ -2429,6 +2428,9 @@ fetch_from_array:
|
|||
ZEND_ASSERT(EG(exception) && "read_dimension() returned NULL without exception");
|
||||
ZVAL_UNDEF(result);
|
||||
}
|
||||
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
|
||||
zend_objects_store_del(obj);
|
||||
}
|
||||
} else {
|
||||
if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
|
||||
if (type != BP_VAR_W && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
|
||||
|
@ -2596,13 +2598,16 @@ try_string_offset:
|
|||
ZVAL_CHAR(result, c);
|
||||
}
|
||||
} else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
|
||||
zend_object *obj = Z_OBJ_P(container);
|
||||
|
||||
GC_ADDREF(obj);
|
||||
if (ZEND_CONST_COND(dim_type == IS_CV, 1) && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
|
||||
dim = ZVAL_UNDEFINED_OP2();
|
||||
}
|
||||
if (dim_type == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) {
|
||||
dim++;
|
||||
}
|
||||
retval = Z_OBJ_HT_P(container)->read_dimension(Z_OBJ_P(container), dim, type, result);
|
||||
retval = obj->handlers->read_dimension(obj, dim, type, result);
|
||||
|
||||
ZEND_ASSERT(result != NULL);
|
||||
if (retval) {
|
||||
|
@ -2614,6 +2619,9 @@ try_string_offset:
|
|||
} else {
|
||||
ZVAL_NULL(result);
|
||||
}
|
||||
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
|
||||
zend_objects_store_del(obj);
|
||||
}
|
||||
} else {
|
||||
if (type != BP_VAR_IS && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
|
||||
container = ZVAL_UNDEFINED_OP1();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue