Skip to content

Commit

Permalink
Fix NPE on ReactTextInputManager.setTextDecorationLine (#46750)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #46750

Fixes #39659

Fix is pretty straightforward, parameter is annotated as Nullable, but is accessed with a `.split` call.
This causes a crash when the `textDecorationLine` property is removed (i.e. is null).

Changelog:
[Android] [Fixed] - Fix NPE on ReactTextInputManager.setTextDecorationLine

Reviewed By: cipolleschi

Differential Revision: D63689492

fbshipit-source-id: 3424897cc40beaeb579e3affd0a87656ff43afee
  • Loading branch information
cortinico authored and facebook-github-bot committed Oct 1, 2024
1 parent 4ede920 commit 41c6ad5
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,9 @@ public void setTextDecorationLine(ReactEditText view, @Nullable String textDecor
view.setPaintFlags(
view.getPaintFlags() & ~(Paint.STRIKE_THRU_TEXT_FLAG | Paint.UNDERLINE_TEXT_FLAG));

if (textDecorationLineString == null) {
return;
}
for (String token : textDecorationLineString.split(" ")) {
if (token.equals("underline")) {
view.setPaintFlags(view.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
Expand Down

0 comments on commit 41c6ad5

Please sign in to comment.