Skip to content

Close the keyword UEnumeration on Locale::getKeywords failure - #23351

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/intl-keywords-uenum-leak
Open

Close the keyword UEnumeration on Locale::getKeywords failure#23351
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/intl-keywords-uenum-leak

Conversation

@iliaal

@iliaal iliaal commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Locale::getKeywords() destroyed the result array and returned when uloc_getKeywordValue() failed, without uenum_close(). Close the enumeration on that path. The success path already does.

@LamentXU123 LamentXU123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote a test for this case, please add it

--TEST--
Locale::getKeywords() closes the keyword enumeration on failure
--EXTENSIONS--
intl
--SKIPIF--
<?php
if (version_compare(INTL_ICU_VERSION, '59.1', '<')) {
    die('skip for ICU >= 59.1');
}
?>
--FILE--
<?php
var_dump(Locale::getKeywords('en@foo=bar!'));
var_dump(intl_get_error_code() === U_ILLEGAL_ARGUMENT_ERROR);
?>
--EXPECT--
bool(false)
bool(true)

uloc_getKeywordValue failure destroyed the result array and returned
without uenum_close(). Close the enumeration on that path. The success
path already closes it.

Audited the other uenum_close site in this file (acceptLanguage).
@iliaal
iliaal force-pushed the fix/intl-keywords-uenum-leak branch from 5901e4e to 8f52ffc Compare August 18, 2026 12:21
@iliaal

iliaal commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Thanks added test, before fix leak shows up on the test via valgrind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants