Skip to content

Commit

Permalink
Fix nil pointer dereference with Must Bind binding error
Browse files Browse the repository at this point in the history
if err is nil err.Error() panics
(eg. c.Bind().Must().JSON(...) successfully binds but panics
  • Loading branch information
ItsMeSamey authored Oct 17, 2024
1 parent 298975a commit 0fa70ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (b *Bind) Must() *Bind {

// Check Should/Must errors and return it by usage.
func (b *Bind) returnErr(err error) error {
if !b.should {
if !b.should && err != nil {
b.ctx.Status(StatusBadRequest)
return NewError(StatusBadRequest, "Bad request: "+err.Error())
}
Expand Down

0 comments on commit 0fa70ab

Please sign in to comment.