check for nil account on actions that need one

This commit is contained in:
Radu Ioan Fericean
2016-06-16 12:09:34 +03:00
parent c8a86788ae
commit 37da594a58

View File

@@ -583,6 +583,9 @@ func removeAccountAction(ub *Account, sq *StatsQueueTriggered, a *Action, acs Ac
}
func removeBalanceAction(ub *Account, sq *StatsQueueTriggered, a *Action, acs Actions) error {
if ub == nil {
return fmt.Errorf("nil account for %s action", utils.ToJSON(a))
}
if _, exists := ub.BalanceMap[a.Balance.GetType()]; !exists {
return utils.ErrNotFound
}
@@ -605,6 +608,9 @@ func removeBalanceAction(ub *Account, sq *StatsQueueTriggered, a *Action, acs Ac
}
func setBalanceAction(acc *Account, sq *StatsQueueTriggered, a *Action, acs Actions) error {
if acc == nil {
return fmt.Errorf("nil account for %s action", utils.ToJSON(a))
}
return acc.setBalanceAction(a)
}