[intl] Add unconstructed-object guard to Collator attribute methods - #260
Open
iliaal wants to merge 1 commit into
Open
[intl] Add unconstructed-object guard to Collator attribute methods#260iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.