From 2c6eb487a31f6c1ae7972126136d0a5e4653c927 Mon Sep 17 00:00:00 2001 From: zhangji Date: Mon, 26 Aug 2019 23:33:22 +0800 Subject: [PATCH] protect slice bounds not out of range (#282) --- pkg/net/http/blademaster/logger.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/net/http/blademaster/logger.go b/pkg/net/http/blademaster/logger.go index 89143fab0..b4c353fe0 100644 --- a/pkg/net/http/blademaster/logger.go +++ b/pkg/net/http/blademaster/logger.go @@ -34,8 +34,10 @@ func Logger() HandlerFunc { caller = noUser } - _metricServerReqCodeTotal.Inc(c.RoutePath[1:], caller, strconv.FormatInt(int64(cerr.Code()), 10)) - _metricServerReqDur.Observe(int64(dt/time.Millisecond), c.RoutePath[1:], caller) + if len(c.RoutePath) > 0 { + _metricServerReqCodeTotal.Inc(c.RoutePath[1:], caller, strconv.FormatInt(int64(cerr.Code()), 10)) + _metricServerReqDur.Observe(int64(dt/time.Millisecond), c.RoutePath[1:], caller) + } lf := log.Infov errmsg := ""