Skip to content

Commit

Permalink
Added a null check to avoid segfault on rewrite query ops (#6191)
Browse files Browse the repository at this point in the history
  • Loading branch information
armadi1809 authored Mar 23, 2024
1 parent 29f57fa commit db9d167
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions modules/caddyhttp/rewrite/rewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ func (rewr *Rewrite) Provision(ctx caddy.Context) error {
}
rep.re = re
}

for _, replacementOp := range rewr.Query.Replace {
err := replacementOp.Provision(ctx)
if err != nil {
return fmt.Errorf("compiling regular expression %s in query rewrite replace operation: %v", replacementOp.SearchRegexp, err)
if rewr.Query != nil {
for _, replacementOp := range rewr.Query.Replace {
err := replacementOp.Provision(ctx)
if err != nil {
return fmt.Errorf("compiling regular expression %s in query rewrite replace operation: %v", replacementOp.SearchRegexp, err)
}
}
}

return nil
}

Expand Down

0 comments on commit db9d167

Please sign in to comment.