fix FilterHandler crash issue
Filter Handler will crash with error assignment to entry in nil map , params from function Tree.Match() maybe nil.
Showing
1 changed file
with
5 additions
and
0 deletions
| ... | @@ -616,6 +616,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -616,6 +616,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 616 | } | 616 | } |
| 617 | if ok, params := filterR.ValidRouter(urlPath); ok { | 617 | if ok, params := filterR.ValidRouter(urlPath); ok { |
| 618 | for k, v := range params { | 618 | for k, v := range params { |
| 619 | if context.Input.Params == nil { | ||
| 620 | context.Input.Params = make(map[string]string) | ||
| 621 | } | ||
| 619 | context.Input.Params[k] = v | 622 | context.Input.Params[k] = v |
| 620 | } | 623 | } |
| 621 | filterR.filterFunc(context) | 624 | filterR.filterFunc(context) |
| ... | @@ -699,9 +702,11 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) | ... | @@ -699,9 +702,11 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) |
| 699 | p[strconv.Itoa(k)] = v | 702 | p[strconv.Itoa(k)] = v |
| 700 | } | 703 | } |
| 701 | } | 704 | } |
| 705 | if p != nil { | ||
| 702 | context.Input.Params = p | 706 | context.Input.Params = p |
| 703 | } | 707 | } |
| 704 | } | 708 | } |
| 709 | } | ||
| 705 | 710 | ||
| 706 | } | 711 | } |
| 707 | 712 | ... | ... |
-
Please register or sign in to post a comment