fix bad offset, fixes #382

This commit is contained in:
Radu Ioan Fericean
2016-02-26 16:33:54 +02:00
parent e55b620a92
commit 8093409209

View File

@@ -47,6 +47,12 @@ func (self *ApierV2) GetAccounts(attr utils.AttrGetAccounts, reply *[]*engine.Ac
if len(accountKeys) == 0 {
return nil
}
if attr.Offset > len(accountKeys) {
attr.Offset = len(accountKeys)
}
if attr.Offset < 0 {
attr.Offset = 0
}
var limitedAccounts []string
if attr.Limit != 0 {
max := math.Min(float64(attr.Offset+attr.Limit), float64(len(accountKeys)))