Skip to content

Commit

Permalink
fix: Changed validation order which leads to crash
Browse files Browse the repository at this point in the history
  • Loading branch information
cheatsnake committed Dec 11, 2022
1 parent fc85dae commit 3ad4b2f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/camp/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ func Generate(w, h int) (Core, error) {
}

func Verify(field [][]int, rowTents, columnTents []int) (VerifyResult, error) {
if len(field) > maxSideSize || len(field[0]) > maxSideSize {
return VerifyResult{}, errors.New(tooLargeFieldSize)
}

if len(field) < minSideSize || len(field[0]) < minSideSize {
return VerifyResult{}, errors.New(tooSmallFieldSize)
}

if len(field) > maxSideSize || len(field[0]) > maxSideSize {
return VerifyResult{}, errors.New(tooLargeFieldSize)
}

if len(field) != len(rowTents) {
return VerifyResult{}, errors.New(incorrectRowTents)
}
Expand Down

0 comments on commit 3ad4b2f

Please sign in to comment.