Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
Guard against random int on 0
Browse files Browse the repository at this point in the history
  • Loading branch information
bakape committed Apr 25, 2019
1 parent 34931de commit 6313449
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions service.go
Expand Up @@ -204,6 +204,11 @@ func (s *Service) filters(tag string) db.Filters {
// bufio.NewWriter.
func (s *Service) NewCaptcha(w io.Writer, colour, background string,
) (id [64]byte, err error) {
if len(s.opts.Tags) == 0 {
err = errors.New("no tags set")
return
}

tag := s.opts.Tags[common.RandomInt(len(s.opts.Tags))]
f := s.filters(tag)
n, err := db.ImageCount(f)
Expand Down

0 comments on commit 6313449

Please sign in to comment.