From 41c6ad55978184cad1a32ec63c2d1f07e8282d5e Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 1 Oct 2024 09:20:53 -0700 Subject: [PATCH] Fix NPE on ReactTextInputManager.setTextDecorationLine (#46750) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46750 Fixes https://github.com/facebook/react-native/issues/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 --- .../facebook/react/views/textinput/ReactTextInputManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index 731c1f6b1086e6..953a89772c2aad 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -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);