From 80934092092b5feff6d692ee9330d5ff1f17c74c Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Fri, 26 Feb 2016 16:33:54 +0200 Subject: [PATCH] fix bad offset, fixes #382 --- apier/v2/accounts.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apier/v2/accounts.go b/apier/v2/accounts.go index dc89590b9..5da921b9f 100644 --- a/apier/v2/accounts.go +++ b/apier/v2/accounts.go @@ -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)))