From 4d4a20a0788b18ad43216bce89735203222be442 Mon Sep 17 00:00:00 2001 From: Lin-1997 <1204878199@qq.com> Date: Wed, 22 Nov 2023 18:07:56 +0800 Subject: [PATCH] fix: nil pointer dereference on item (#1290) --- plugin/statis/base/cachecall.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/statis/base/cachecall.go b/plugin/statis/base/cachecall.go index 9c9cd08af..225faa878 100644 --- a/plugin/statis/base/cachecall.go +++ b/plugin/statis/base/cachecall.go @@ -62,12 +62,12 @@ func (c *CacheStatics) Add(ac metrics.CallMetric) { index := fmt.Sprintf("%v", ac.Protocol) item, exist := c.statis[index] if !exist { - c.statis[index] = &CacheCallStatisItem{ + item = &CacheCallStatisItem{ cacheType: ac.Protocol, } + c.statis[index] = item } - item = c.statis[index] if ac.Success { item.hitCount += int64(ac.Times) } else {