From 13c49e200615d9f04a272c3d3d76f8b6fc56417c Mon Sep 17 00:00:00 2001 From: Charles Dick Date: Thu, 10 Mar 2016 07:21:53 -0800 Subject: [PATCH] Fix null deref in RN timer code Reviewed By: astreet Differential Revision: D3029772 fb-gh-sync-id: 0af13208659093b14013c0ee3c00b2438fadca9c shipit-source-id: 0af13208659093b14013c0ee3c00b2438fadca9c --- .../com/facebook/react/modules/core/Timing.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java b/ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java index 79a5b6b3f1..91a6ddc7ca 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java @@ -241,12 +241,17 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl @ReactMethod public void deleteTimer(ExecutorToken executorToken, int timerId) { synchronized (mTimerGuard) { - Timer timer = mTimerIdsToTimers.get(executorToken).get(timerId); - if (timer != null) { - // We may have already called/removed it - mTimerIdsToTimers.remove(timerId); - mTimers.remove(timer); + SparseArray timersForContext = mTimerIdsToTimers.get(executorToken); + if (timersForContext == null) { + return; } + Timer timer = timersForContext.get(timerId); + if (timer == null) { + return; + } + // We may have already called/removed it + mTimerIdsToTimers.remove(timerId); + mTimers.remove(timer); } } }