Added a null check to avoid segfault on rewrite query ops (#6191)

This commit is contained in:
Aziz Rmadi 2024-03-23 00:51:34 -05:00 committed by GitHub
parent 29f57faa86
commit db9d167354
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 5 deletions

View File

@ -117,13 +117,15 @@ func (rewr *Rewrite) Provision(ctx caddy.Context) error {
} }
rep.re = re rep.re = re
} }
if rewr.Query != nil {
for _, replacementOp := range rewr.Query.Replace { for _, replacementOp := range rewr.Query.Replace {
err := replacementOp.Provision(ctx) err := replacementOp.Provision(ctx)
if err != nil { if err != nil {
return fmt.Errorf("compiling regular expression %s in query rewrite replace operation: %v", replacementOp.SearchRegexp, err) return fmt.Errorf("compiling regular expression %s in query rewrite replace operation: %v", replacementOp.SearchRegexp, err)
} }
} }
}
return nil return nil
} }