-
Notifications
You must be signed in to change notification settings - Fork 148
fix(UBSAN): ensure [RCTUITextField validAttributesForMarkedText]
Is non null
#2515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses an issue where the method [RCTUITextField validAttributesForMarkedText] was returning nil, which violates Apple's documentation and triggers UBSAN warnings. The change ensures the method returns an empty array as a fallback instead of nil.
- Updated the return value of validAttributesForMarkedText to use a nil coalescing fallback (@[]).
Comments suppressed due to low confidence (1)
packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm:164
- The nil coalescing operator ensures a non-null return value, which is required by the API contract. Please verify that self.currentEditor always returns an object of type NSTextView to avoid potential issues with unsafe type casting.
return ((NSTextView *)self.currentEditor).validAttributesForMarkedText ?: @[];
@copilot Could you backport this PR to the following branches?
|
Summary:
Internally, we build with UndefinedBehaviorSanitizer, which caught an instance of a method returning nil while marked as non null. Apple documentation says that method should return an empty array as a fallback, so let's do that.
Test Plan:
Tested internally.