From 863e88194336a7baefbceb266f56d60d6a002da5 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Tue, 1 Nov 2016 23:46:13 -0700 Subject: do not allow return length longer than number of values in bucket --- system/db/content.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/db/content.go b/system/db/content.go index 84695cc..03e6a41 100644 --- a/system/db/content.go +++ b/system/db/content.go @@ -215,6 +215,7 @@ func Query(namespace string, opts QueryOptions) [][]byte { store.View(func(tx *bolt.Tx) error { b := tx.Bucket([]byte(namespace)) c := b.Cursor() + n := b.Stats().KeyN i := 0 // count of num posts added cur := 0 // count of where cursor is @@ -226,7 +227,7 @@ func Query(namespace string, opts QueryOptions) [][]byte { continue } - if i >= opts.Count { + if i >= opts.Count || cur > n { break } @@ -241,7 +242,7 @@ func Query(namespace string, opts QueryOptions) [][]byte { continue } - if i >= opts.Count { + if i >= opts.Count || cur > n { break } -- cgit v1.2.3