Fix null deref in RN timer code

Reviewed By: astreet

Differential Revision: D3029772

fb-gh-sync-id: 0af13208659093b14013c0ee3c00b2438fadca9c
shipit-source-id: 0af13208659093b14013c0ee3c00b2438fadca9c
This commit is contained in:
Charles Dick 2016-03-10 07:21:53 -08:00 committed by Facebook Github Bot 4
parent e9c79f85ba
commit 13c49e2006
1 changed files with 10 additions and 5 deletions

View File

@ -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) {
SparseArray<Timer> 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);
}
}
}
}