From 6c52907f2bd4361e795b42cda43c065e24c6f700 Mon Sep 17 00:00:00 2001 From: Danny Tylman Date: Thu, 8 Sep 2016 11:40:53 +0300 Subject: [PATCH] fixes #416: panic in collector_heap --- search/collectors/heap.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/search/collectors/heap.go b/search/collectors/heap.go index 1c834e9c..3f62867c 100644 --- a/search/collectors/heap.go +++ b/search/collectors/heap.go @@ -40,6 +40,9 @@ func (c *collectStoreHeap) RemoveLast() *search.DocumentMatch { func (c *collectStoreHeap) Final(skip int, fixup collectorFixup) (search.DocumentMatchCollection, error) { count := c.Len() size := count - skip + if size <= 0 { + return make(search.DocumentMatchCollection, 0), nil + } rv := make(search.DocumentMatchCollection, size) for count > 0 { count--