diff --git a/digest.go b/digest.go index d866b6b..3eaaf7a 100644 --- a/digest.go +++ b/digest.go @@ -80,7 +80,13 @@ func (da *DigestAuth) Purge(count int) { } cache := digestCache(entries) sort.Sort(cache) - for _, client := range cache[:count] { + + limit := count + if len(cache) < count { + limit = len(cache) - 1 + } + + for _, client := range cache[:limit] { delete(da.clients, client.nonce) } }