fix upper limit in GetAccounts

This commit is contained in:
Radu Ioan Fericean
2015-07-28 15:35:57 +03:00
parent 03f43dee37
commit 4cb2ec80fe

View File

@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package v1
import (
"math"
"regexp"
"strings"
"time"
@@ -255,7 +256,8 @@ func (self *ApierV1) GetAccounts(attr utils.AttrGetAccounts, reply *[]*engine.Ac
}
var limitedAccounts []string
if attr.Limit != 0 {
limitedAccounts = accountKeys[attr.Offset : attr.Offset+attr.Limit]
max := math.Min(float64(attr.Offset+attr.Limit), float64(len(accountKeys)))
limitedAccounts = accountKeys[attr.Offset:int(max)]
} else {
limitedAccounts = accountKeys[attr.Offset:]
}