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 коммит произвёл Facebook Github Bot 4
Родитель e9c79f85ba
Коммит 13c49e2006
1 изменённых файлов: 10 добавлений и 5 удалений

Просмотреть файл

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