From 24a1f5c66c8633f9b41eef45df3297ffc1d2b606 Mon Sep 17 00:00:00 2001 From: Mike Masam Date: Mon, 9 May 2022 10:18:37 -0700 Subject: [PATCH] Handle possible null exception on ReactEditText with AppCompat 1.4.0 (#33769) Summary: This Change fixes a possible null exception as the user uses AppCompat 1.4.0 as a dependency in their App and uses a `TextInput` component. The exception may happen as `mFabricViewStateManager` is accessed during the constructor of the superclass, and is not yet initialized. - For reference, commit #e21f8ec34984551f87a306672160cc88e67e4793 fixes the crash which was already happening. Possible null exception as `mFabricViewStateManager` is accessed during the constructor of the superclass, white it is not yet initialized. This commit #e21f8ec34984551f87a306672160cc88e67e4793 fixes the crash which was already happening, accessing of mFabricViewStateManager before initialization, and left another one of the call of the same nature. ## Changelog Fix: accessing `mFabricViewStateManager` before initialization. [JavaScript] [Fixed] - accessing `mFabricViewStateManager` before initialization. Pull Request resolved: https://github.com/facebook/react-native/pull/33769 Test Plan: no external tool was used. Reviewed By: javache Differential Revision: D36205441 Pulled By: cortinico fbshipit-source-id: f3fca69224c7794757514f026a5293b213986186 --- .../java/com/facebook/react/views/textinput/ReactEditText.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index 9098e98b25d..0b96e0b2047 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -642,7 +642,7 @@ public class ReactEditText extends AppCompatEditText // This is hacked in for Fabric. When we delete non-Fabric code, we might be able to simplify or // clean this up a bit. private void addSpansForMeasurement(Spannable spannable) { - if (!mFabricViewStateManager.hasStateWrapper()) { + if (mFabricViewStateManager != null && !mFabricViewStateManager.hasStateWrapper()) { return; }