Skip to content

Commit f3ed172

Browse files
committed
uri: Remove uri_parser_name parameter of uri_unserialize()
The parser for a given object is already known from the object itself and particularly must never change. Reassigning the value in `uri_unserialize()` is just unsafe, especially since the existing `->uri` is freed with the destructor of the reassigned parser. Just rely on the `->parser` field being set to the correct value.
1 parent 2610f39 commit f3ed172

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

ext/uri/php_uri.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, __serialize)
727727
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &arr);
728728
}
729729

730-
static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS, const char *uri_parser_name)
730+
static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS)
731731
{
732732
HashTable *data;
733733

@@ -763,7 +763,6 @@ static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS, const char *uri_parser
763763
}
764764

765765
uri_internal_t *internal_uri = uri_internal_from_obj(object);
766-
internal_uri->parser = uri_parser_by_name(uri_parser_name, strlen(uri_parser_name));
767766
if (internal_uri->uri != NULL) {
768767
internal_uri->parser->free_uri(internal_uri->uri);
769768
}
@@ -789,7 +788,7 @@ static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS, const char *uri_parser
789788

790789
PHP_METHOD(Uri_Rfc3986_Uri, __unserialize)
791790
{
792-
uri_unserialize(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PARSER_RFC3986);
791+
uri_unserialize(INTERNAL_FUNCTION_PARAM_PASSTHRU);
793792
}
794793

795794
PHP_METHOD(Uri_Rfc3986_Uri, __debugInfo)
@@ -942,7 +941,7 @@ PHP_METHOD(Uri_WhatWg_Url, __serialize)
942941

943942
PHP_METHOD(Uri_WhatWg_Url, __unserialize)
944943
{
945-
uri_unserialize(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PARSER_WHATWG);
944+
uri_unserialize(INTERNAL_FUNCTION_PARAM_PASSTHRU);
946945
}
947946

948947
PHP_METHOD(Uri_WhatWg_Url, __debugInfo)

0 commit comments

Comments
 (0)