Skip to content

Commit

Permalink
Merge pull request #66 from jpbetz/freelist-check
Browse files Browse the repository at this point in the history
Panic if page provided to freelist.read is incorrect page type.
  • Loading branch information
gyuho committed Nov 16, 2017
2 parents 3c6cbfb + 237a4fc commit f4ebd07
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions freelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f4ebd07

Please sign in to comment.