Skip to content

Commit f4ebd07

Browse files
authored
Merge pull request #66 from jpbetz/freelist-check
Panic if page provided to freelist.read is incorrect page type.
2 parents 3c6cbfb + 237a4fc commit f4ebd07

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

freelist.go

+3
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ func (f *freelist) freed(pgid pgid) bool {
233233

234234
// read initializes the freelist from a freelist page.
235235
func (f *freelist) read(p *page) {
236+
if (p.flags & freelistPageFlag) == 0 {
237+
panic(fmt.Sprintf("invalid freelist page: %d, page type is %s", p.id, p.typ()))
238+
}
236239
// If the page.count is at the max uint16 value (64k) then it's considered
237240
// an overflow and the size of the freelist is stored as the first element.
238241
idx, count := 0, int(p.count)

0 commit comments

Comments
 (0)