From 92410e067395f10c8c93fad62c3e6c4b7aca82f0 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Thu, 18 Aug 2016 08:44:57 -0600 Subject: fix Go 1.7 pointer reference bug This commit fixes a bug where page end-of-header pointers were being converted to byte slices even when the pointer did not point to allocated memory. This occurs with pages that have a `page.count` of zero. Note: This was not an issue in Go 1.6 but the new Go 1.7 SSA backend handles `nil` checks differently. See https://github.com/golang/go/issues/16772 --- page.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'page.go') diff --git a/page.go b/page.go index 4a55528..7651a6b 100644 --- a/page.go +++ b/page.go @@ -62,6 +62,9 @@ func (p *page) leafPageElement(index uint16) *leafPageElement { // leafPageElements retrieves a list of leaf nodes. func (p *page) leafPageElements() []leafPageElement { + if p.count == 0 { + return nil + } return ((*[0x7FFFFFF]leafPageElement)(unsafe.Pointer(&p.ptr)))[:] } @@ -72,6 +75,9 @@ func (p *page) branchPageElement(index uint16) *branchPageElement { // branchPageElements retrieves a list of branch nodes. func (p *page) branchPageElements() []branchPageElement { + if p.count == 0 { + return nil + } return ((*[0x7FFFFFF]branchPageElement)(unsafe.Pointer(&p.ptr)))[:] } -- cgit v1.2.3