Skip to content

Commit d4187c7

Browse files
committed
uri: Call the proper clone_obj handler in uri_write_component_ex()
For external URI implementation it's possible that the `->clone_obj` handler does not match `uri_clone_obj_handler()`. Use the handler of the object instead of making assumptions.
1 parent 3bf495b commit d4187c7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ext/uri/php_uri_common.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,22 @@ void uri_read_component(INTERNAL_FUNCTION_PARAMETERS, uri_property_name_t proper
8383

8484
static void uri_write_component_ex(INTERNAL_FUNCTION_PARAMETERS, uri_property_name_t property_name, zval *property_zv)
8585
{
86+
zend_object *old_object = Z_OBJ_P(ZEND_THIS);
8687
uri_internal_t *internal_uri = Z_URI_INTERNAL_P(ZEND_THIS);
8788
URI_ASSERT_INITIALIZATION(internal_uri);
8889

90+
zend_object *new_object = old_object->handlers->clone_obj(old_object);
91+
if (new_object == NULL) {
92+
RETURN_THROWS();
93+
}
94+
8995
const uri_property_handler_t *property_handler = uri_property_handler_from_internal_uri(internal_uri, property_name);
9096
ZEND_ASSERT(property_handler != NULL);
9197

92-
zend_object *new_object = uri_clone_obj_handler(Z_OBJ_P(ZEND_THIS));
93-
ZEND_ASSERT(new_object != NULL);
94-
9598
uri_internal_t *new_internal_uri = uri_internal_from_obj(new_object);
9699
URI_ASSERT_INITIALIZATION(new_internal_uri);
97100
if (UNEXPECTED(property_handler->write_func == NULL)) {
98-
zend_readonly_property_modification_error_ex(ZSTR_VAL(Z_OBJ_P(ZEND_THIS)->ce->name),
101+
zend_readonly_property_modification_error_ex(ZSTR_VAL(old_object->ce->name),
99102
ZSTR_VAL(get_known_string_by_property_name(property_name)));
100103
zend_object_release(new_object);
101104
RETURN_THROWS();
@@ -110,7 +113,7 @@ static void uri_write_component_ex(INTERNAL_FUNCTION_PARAMETERS, uri_property_na
110113
}
111114

112115
ZEND_ASSERT(Z_ISUNDEF(errors));
113-
RETVAL_OBJ(new_object);
116+
RETURN_OBJ(new_object);
114117
}
115118

116119
void uri_write_component_str(INTERNAL_FUNCTION_PARAMETERS, uri_property_name_t property_name)

0 commit comments

Comments
 (0)