From 2d111df99d18e79110e8aed707a229ff737c27cb Mon Sep 17 00:00:00 2001 From: Adam Finn Tulinius Date: Thu, 15 Nov 2018 13:29:48 +0100 Subject: [PATCH] Make sure the limit operator doesn't cause out-of-bounds errors This fixes #27 --- filter/filter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filter/filter.go b/filter/filter.go index 0c51917..2db23fe 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -29,8 +29,8 @@ func FilterHosts(allHosts []nix.Host, skip int, every int, limit int) (hosts []n } } - // limit to $limit hosts - if limit > 0 { + // limit to $limit hosts, making sure not to go out of bounds either + if limit > 0 && limit < len(hosts) { return hosts[:limit] } else { return hosts