diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-03-13 14:39:28 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-03-13 14:39:28 -0600 |
commit | 4132080333b1cb0e96b7b8732e763f96d69074ee (patch) | |
tree | ca9076ef7bf7d42ce9ae38a32df5c52cee6ce002 /cursor.go | |
parent | README (diff) | |
download | dedo-4132080333b1cb0e96b7b8732e763f96d69074ee.tar.gz dedo-4132080333b1cb0e96b7b8732e763f96d69074ee.tar.xz |
Fix Cursor.Last() on empty buckets.
@tv42 reported that creating a cursor on an empty bucket and then calling
Cursor.Last() causes an index out of range error and panics. This commit
adds a check for the page's item count being greater than zero.
Fixes #63.
Diffstat (limited to 'cursor.go')
-rw-r--r-- | cursor.go | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -235,7 +235,7 @@ func (c *Cursor) nsearch(key []byte) { // keyValue returns the key and value of the current leaf element. func (c *Cursor) keyValue() ([]byte, []byte) { ref := &c.stack[len(c.stack)-1] - if ref.index >= ref.count() { + if ref.count() == 0 || ref.index >= ref.count() { return nil, nil } |