From 237a4fcb31db8d1249eb47ab773b2dbe2ae8b38b Mon Sep 17 00:00:00 2001 From: Joe Betz Date: Wed, 15 Nov 2017 15:52:34 -0800 Subject: [PATCH] Panic if page provided to freelist.read is incorrect page type. --- freelist.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/freelist.go b/freelist.go index 78e71cb..318cc3b 100644 --- a/freelist.go +++ b/freelist.go @@ -233,6 +233,9 @@ func (f *freelist) freed(pgid pgid) bool { // read initializes the freelist from a freelist page. func (f *freelist) read(p *page) { + if (p.flags & freelistPageFlag) == 0 { + panic(fmt.Sprintf("invalid freelist page: %d, page type is %s", p.id, p.typ())) + } // If the page.count is at the max uint16 value (64k) then it's considered // an overflow and the size of the freelist is stored as the first element. idx, count := 0, int(p.count)