Просмотр исходного кода

fix: execOnCalendarFile, avoid possible crash deleting nil timers

jamesread 5 месяцев назад
Родитель
Сommit
b3430e3a5c
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      service/internal/oncalendarfile/calendar.go

+ 4 - 1
service/internal/oncalendarfile/calendar.go

@@ -132,7 +132,10 @@ func registerTimer(action *config.Action, instant time.Time, timer *time.Timer,
 
 func unregisterTimer(action *config.Action, instant time.Time) {
 	scheduleMapMutex.Lock()
-	delete(scheduleMap[action.ID].timers, instant)
+	v := scheduleMap[action.ID]
+	if v.timers != nil {
+		delete(v.timers, instant)
+	}
 	scheduleMapMutex.Unlock()
 }