From 67d0706ea44bab5472619ce8308c0a0b45c229bb Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 12 Sep 2026 20:11:14 -0400 Subject: [PATCH] crypto/tls: make deleting a missing session cache key a no-op lruSessionCache.Put is documented to remove the entry for sessionKey when cs is nil, but it only did so if the key was already in the cache. Otherwise it inserted an entry with a nil state, evicting the least recently used entry if the cache was full. Fixes #79861 Change-Id: Ie9abd6921a1a949f3fa796b63a235790fa42fb87 GitHub-Last-Rev: db2c9b9 GitHub-Pull-Request: #81042 Reviewed-on: https://go-review.googlesource.com/c/go/+/819960 Auto-Submit: Filippo Valsorda Reviewed-by: David Chase Reviewed-by: Dmitri Shuralyov Reviewed-by: Filippo Valsorda LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com --- common.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common.go b/common.go index efd4f6d..cdda38a 100644 --- a/common.go +++ b/common.go @@ -1770,6 +1770,10 @@ func (c *lruSessionCache) Put(sessionKey string, cs *ClientSessionState) { return } + if cs == nil { + return + } + if c.q.Len() < c.capacity { entry := &lruSessionCacheEntry{sessionKey, cs} c.m[sessionKey] = c.q.PushFront(entry)