Skip to content

Commit 6694d28

Browse files
committed
Add garbage_ptr to write_property handler
1 parent 4c580af commit 6694d28

30 files changed

+106
-111
lines changed

Zend/tests/gh10168/assign_prop.phpt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
--TEST--
22
GH-10168: Assign prop
3-
--XFAIL--
43
--FILE--
54
<?php
65

Zend/tests/gh10168/assign_prop_ref.phpt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
--TEST--
22
GH-10168: Assign prop ref
3-
--XFAIL--
43
--FILE--
54
<?php
65

Zend/tests/gh10168/assign_prop_ref_with_prop_ref.phpt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
--TEST--
22
GH-10168: Assign prop ref with prop ref
3-
--XFAIL--
43
--FILE--
54
<?php
65

Zend/tests/gh10168/assign_prop_with_prop_ref.phpt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
--TEST--
22
GH-10168: Assign prop with prop ref
3-
--XFAIL--
43
--FILE--
54
<?php
65

Zend/tests/gh10168/assign_untyped_prop.phpt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
--TEST--
22
GH-10168: Assign prop
3-
--XFAIL--
43
--FILE--
54
<?php
65

Zend/tests/gh10168/assign_untyped_prop_ref.phpt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
--TEST--
22
GH-10168: Assign prop ref
3-
--XFAIL--
43
--FILE--
54
<?php
65

Zend/tests/gh10168/assign_untyped_prop_ref_with_prop_ref.phpt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
--TEST--
22
GH-10168: Assign prop ref with prop ref
3-
--XFAIL--
43
--FILE--
54
<?php
65

Zend/tests/gh10168/assign_untyped_prop_with_prop_ref.phpt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
--TEST--
22
GH-10168: Assign prop with prop ref
3-
--XFAIL--
43
--FILE--
54
<?php
65

Zend/zend_API.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */
13281328
EG(fake_scope) = Z_OBJCE_P(obj);
13291329
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(properties, key, value) {
13301330
if (key) {
1331-
write_property(zobj, key, value, NULL);
1331+
write_property(zobj, key, value, NULL, NULL);
13321332
}
13331333
} ZEND_HASH_FOREACH_END();
13341334
EG(fake_scope) = old_scope;
@@ -2208,7 +2208,7 @@ ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, z
22082208
zend_string *str;
22092209

22102210
str = zend_string_init(key, key_len, 0);
2211-
Z_OBJ_HANDLER_P(arg, write_property)(Z_OBJ_P(arg), str, value, NULL);
2211+
Z_OBJ_HANDLER_P(arg, write_property)(Z_OBJ_P(arg), str, value, NULL, NULL);
22122212
zend_string_release_ex(str, 0);
22132213
}
22142214
/* }}} */
@@ -4643,7 +4643,7 @@ ZEND_API void zend_update_property_ex(zend_class_entry *scope, zend_object *obje
46434643

46444644
EG(fake_scope) = scope;
46454645

4646-
object->handlers->write_property(object, name, value, NULL);
4646+
object->handlers->write_property(object, name, value, NULL, NULL);
46474647

46484648
EG(fake_scope) = old_scope;
46494649
}
@@ -4657,7 +4657,7 @@ ZEND_API void zend_update_property(zend_class_entry *scope, zend_object *object,
46574657
EG(fake_scope) = scope;
46584658

46594659
property = zend_string_init(name, name_length, 0);
4660-
object->handlers->write_property(object, property, value, NULL);
4660+
object->handlers->write_property(object, property, value, NULL, NULL);
46614661
zend_string_release_ex(property, 0);
46624662

46634663
EG(fake_scope) = old_scope;

Zend/zend_execute.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ static zend_never_inline void zend_post_incdec_overloaded_property(zend_object *
20362036
} else {
20372037
decrement_function(&z_copy);
20382038
}
2039-
object->handlers->write_property(object, name, &z_copy, cache_slot);
2039+
object->handlers->write_property(object, name, &z_copy, cache_slot, NULL);
20402040
OBJ_RELEASE(object);
20412041
zval_ptr_dtor(&z_copy);
20422042
if (z == &rv) {
@@ -2069,7 +2069,7 @@ static zend_never_inline void zend_pre_incdec_overloaded_property(zend_object *o
20692069
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
20702070
ZVAL_COPY(EX_VAR(opline->result.var), &z_copy);
20712071
}
2072-
object->handlers->write_property(object, name, &z_copy, cache_slot);
2072+
object->handlers->write_property(object, name, &z_copy, cache_slot, NULL);
20732073
OBJ_RELEASE(object);
20742074
zval_ptr_dtor(&z_copy);
20752075
if (z == &rv) {
@@ -2092,7 +2092,7 @@ static zend_never_inline void zend_assign_op_overloaded_property(zend_object *ob
20922092
return;
20932093
}
20942094
if (zend_binary_op(&res, z, value OPLINE_CC) == SUCCESS) {
2095-
object->handlers->write_property(object, name, &res, cache_slot);
2095+
object->handlers->write_property(object, name, &res, cache_slot, NULL);
20962096
}
20972097
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
20982098
ZVAL_COPY(EX_VAR(opline->result.var), &res);

Zend/zend_object_handlers.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ static bool verify_readonly_initialization_access(
795795
return false;
796796
}
797797

798-
ZEND_API zval *zend_std_write_property(zend_object *zobj, zend_string *name, zval *value, void **cache_slot) /* {{{ */
798+
ZEND_API zval *zend_std_write_property(zend_object *zobj, zend_string *name, zval *value, void **cache_slot, zend_refcounted **garbage_ptr) /* {{{ */
799799
{
800800
zval *variable_ptr, tmp;
801801
uintptr_t property_offset;
@@ -837,8 +837,11 @@ ZEND_API zval *zend_std_write_property(zend_object *zobj, zend_string *name, zva
837837
}
838838

839839
found:
840-
variable_ptr = zend_assign_to_variable(
841-
variable_ptr, value, IS_TMP_VAR, property_uses_strict_types());
840+
if (garbage_ptr) {
841+
variable_ptr = zend_assign_to_variable_ex(variable_ptr, value, IS_TMP_VAR, property_uses_strict_types(), garbage_ptr);
842+
} else {
843+
variable_ptr = zend_assign_to_variable(variable_ptr, value, IS_TMP_VAR, property_uses_strict_types());
844+
}
842845
goto exit;
843846
}
844847
if (Z_PROP_FLAG_P(variable_ptr) == IS_PROP_UNINIT) {

Zend/zend_object_handlers.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ typedef zval *(*zend_object_read_dimension_t)(zend_object *object, zval *offset,
4646
/* Used to set property of the object
4747
You must return the final value of the assigned property.
4848
*/
49-
typedef zval *(*zend_object_write_property_t)(zend_object *object, zend_string *member, zval *value, void **cache_slot);
49+
typedef zval *(*zend_object_write_property_t)(zend_object *object, zend_string *member, zval *value, void **cache_slot, zend_refcounted **garbage_ptr);
5050

5151
/* Used to set dimension of the object */
5252
typedef void (*zend_object_write_dimension_t)(zend_object *object, zval *offset, zval *value);
@@ -212,7 +212,7 @@ ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp);
212212
ZEND_API zend_result zend_std_cast_object_tostring(zend_object *object, zval *writeobj, int type);
213213
ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot);
214214
ZEND_API zval *zend_std_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv);
215-
ZEND_API zval *zend_std_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot);
215+
ZEND_API zval *zend_std_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot, zend_refcounted **garbage_ptr);
216216
ZEND_API int zend_std_has_property(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot);
217217
ZEND_API void zend_std_unset_property(zend_object *object, zend_string *member, void **cache_slot);
218218
ZEND_API zval *zend_std_read_dimension(zend_object *object, zval *offset, int type, zval *rv);

Zend/zend_vm_def.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2487,7 +2487,7 @@ ZEND_VM_C_LABEL(fast_assign_obj):
24872487
ZVAL_DEREF(value);
24882488
}
24892489

2490-
value = zobj->handlers->write_property(zobj, name, value, (OP2_TYPE == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL);
2490+
value = zobj->handlers->write_property(zobj, name, value, (OP2_TYPE == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL, &garbage);
24912491

24922492
if (OP2_TYPE != IS_CONST) {
24932493
zend_tmp_string_release(tmp_name);

0 commit comments

Comments
 (0)