Skip to content

Commit

Permalink
Fix #131: Return error on pageNumber = 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Armen Boursalian committed Dec 12, 2017
1 parent 978d94d commit 6613014
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pdf/model/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,11 @@ func (this *PdfReader) GetPage(pageNumber int) (*PdfPage, error) {
if len(this.pageList) < pageNumber {
return nil, errors.New("Invalid page number (page count too short)")
}
page := this.PageList[pageNumber-1]
idx := pageNumber - 1
if idx < 0 {
return nil, fmt.Errorf("Page numbering must start at 1")
}
page := this.PageList[idx]

return page, nil
}
Expand Down

0 comments on commit 6613014

Please sign in to comment.