From f335cd8481ddcdcebe5ff6f4c75e0fd8e806801e Mon Sep 17 00:00:00 2001 From: guillaumemichel Date: Tue, 17 Dec 2024 11:05:05 +0100 Subject: [PATCH] fix ants removal npe --- queen.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/queen.go b/queen.go index 7308cdc..c8e7787 100644 --- a/queen.go +++ b/queen.go @@ -313,7 +313,8 @@ func (q *Queen) routine(ctx context.Context) { logger.Debugf("need %d extra ants", len(missingKeys)) logger.Debugf("removing %d ants", len(excessAntsIndices)) - // remove ants + // remove ants - sort indices in descending order to remove from end first + sort.Sort(sort.Reverse(sort.IntSlice(excessAntsIndices))) returnedKeys := make([]crypto.PrivKey, len(excessAntsIndices)) for i, index := range excessAntsIndices { ant := q.ants[index]