Skip to content

[intl] Add unconstructed-object guard to Collator attribute methods - #260

Open
iliaal wants to merge 1 commit into
PHP-8.4from
fix/collator-attr-uninit-84
Open

[intl] Add unconstructed-object guard to Collator attribute methods#260
iliaal wants to merge 1 commit into
PHP-8.4from
fix/collator-attr-uninit-84

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Collator::getAttribute(), setAttribute(), getStrength() and setStrength() skipped the unconstructed-object guard that compare(), getLocale(), sort() and getSortKey() already have, so a subclass omitting parent::__construct() reached ICU with a NULL collator and silently returned bogus values (getAttribute() returned -1, setStrength() reported success). Add the same 'Object not initialized' Error guard to the four attribute/strength methods in ext/intl/collator/collator_attr.c, with a new .phpt covering all four; the full ext/intl suite passes with no new failures.

Collator::getAttribute(), setAttribute(), getStrength() and
setStrength() dereferenced a NULL ICU collator when invoked on an
object whose constructor skipped parent::__construct(), silently
returning bogus values or crashing, while compare(), getLocale(),
sort() and getSortKey() already throw 'Object not initialized'. Apply
the same guard to the four attribute/strength methods; sibling audit
found no other Collator methods touching co->ucoll without a check.
@iliaal iliaal closed this Aug 24, 2026
@iliaal iliaal reopened this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant