Skip to content

Commit ea5239e

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 7a3271c commit ea5239e

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
@@ -729,7 +729,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, __serialize)
729729
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &arr);
730730
}
731731

732-
static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS, const char *uri_parser_name)
732+
static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS)
733733
{
734734
HashTable *data;
735735

@@ -765,7 +765,6 @@ static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS, const char *uri_parser
765765
}
766766

767767
uri_internal_t *internal_uri = uri_internal_from_obj(object);
768-
internal_uri->parser = uri_parser_by_name(uri_parser_name, strlen(uri_parser_name));
769768
if (internal_uri->uri != NULL) {
770769
internal_uri->parser->free_uri(internal_uri->uri);
771770
}
@@ -791,7 +790,7 @@ static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS, const char *uri_parser
791790

792791
PHP_METHOD(Uri_Rfc3986_Uri, __unserialize)
793792
{
794-
uri_unserialize(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PARSER_RFC3986);
793+
uri_unserialize(INTERNAL_FUNCTION_PARAM_PASSTHRU);
795794
}
796795

797796
PHP_METHOD(Uri_Rfc3986_Uri, __debugInfo)
@@ -944,7 +943,7 @@ PHP_METHOD(Uri_WhatWg_Url, __serialize)
944943

945944
PHP_METHOD(Uri_WhatWg_Url, __unserialize)
946945
{
947-
uri_unserialize(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PARSER_WHATWG);
946+
uri_unserialize(INTERNAL_FUNCTION_PARAM_PASSTHRU);
948947
}
949948

950949
PHP_METHOD(Uri_WhatWg_Url, __debugInfo)

0 commit comments

Comments
 (0)