Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ PHP NEWS
. Fixed memory management of Uri\WhatWg\Url objects. (timwolla)
. Fixed memory management of the internal "parse_url" URI parser.
(timwolla)
. Fixed double-free when assigning to $errors fails when using
the Uri\WhatWg\Url parser. (timwolla)
. Clean up naming of internal API. (timwolla)

28 Aug 2025, PHP 8.5.0beta2
Expand Down
2 changes: 1 addition & 1 deletion ext/uri/php_uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ static zend_result pass_errors_by_ref_and_free(zval *errors_zv, zval *errors)

ZEND_TRY_ASSIGN_REF_ARR(errors_zv, Z_ARRVAL_P(errors));
if (EG(exception)) {
zval_ptr_dtor(errors);
return FAILURE;
}

Expand Down Expand Up @@ -360,6 +359,7 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) PHPAPI void php_uri_instantiate_uri(
}

if (pass_errors_by_ref_and_free(errors_zv, &errors) == FAILURE) {
uri_parser->free_uri(uri);
RETURN_THROWS();
}

Expand Down
21 changes: 21 additions & 0 deletions ext/uri/tests/057.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Test assigning errors by reference fails
--EXTENSIONS--
uri
--FILE--
<?php

class Foo {
public string $x = '';
}

$f = new Foo();
try {
Uri\WhatWg\Url::parse(" https://example.org ", errors: $f->x);
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
TypeError: Cannot assign array to reference held by property Foo::$x of type string