Commit 2f9711d
Fix race causing NPE in AccessibilityInfoModule event emission (#55792)
Summary:
Pull Request resolved: #55792
Fixing this reported crash:
```
android:java.lang.NullPointerException:com.facebook.react.modules.accessibilityinfo.AccessibilityInfoModule.updateAndSendTouchExplorationChangeEvent:unknown
```
Prevent `NullPointerException` crashes by removing a TOCTOU (Time-Of-Check to Time-Of-Use) race when emitting accessibility state change events.
The React context can become invalid between check and use; using a safe call on `getReactApplicationContextIfActiveOrWarn` ensures events are only sent when the context is active.
Changelog: [Internal]
---
Reviewed By: mdvacca
Differential Revision: D94558522
fbshipit-source-id: 46edbf745b482e7d212ae5f0ed7a9fa3db7c7ba21 parent 703fe8b commit 2f9711d
1 file changed
Lines changed: 4 additions & 10 deletions
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo
Lines changed: 4 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
| 214 | + | |
| 215 | + | |
219 | 216 | | |
220 | 217 | | |
221 | 218 | | |
222 | 219 | | |
223 | 220 | | |
224 | 221 | | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
| 222 | + | |
| 223 | + | |
230 | 224 | | |
231 | 225 | | |
232 | 226 | | |
| |||
0 commit comments