From 87e8bcc9bea41794117b9b34201b3fe261465af3 Mon Sep 17 00:00:00 2001 From: "MrLee.Kun" Date: Fri, 19 Jun 2015 11:19:35 +0800 Subject: [PATCH] fix FilterHandler crash issue Filter Handler will crash with error assignment to entry in nil map , params from function Tree.Match() maybe nil. --- router.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/router.go b/router.go index ca6d917a..3e1ebab3 100644 --- a/router.go +++ b/router.go @@ -616,6 +616,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) } if ok, params := filterR.ValidRouter(urlPath); ok { for k, v := range params { + if context.Input.Params == nil { + context.Input.Params = make(map[string]string) + } context.Input.Params[k] = v } filterR.filterFunc(context) @@ -699,7 +702,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) p[strconv.Itoa(k)] = v } } - context.Input.Params = p + if p != nil { + context.Input.Params = p + } } }