From dc10aeeff853c2156c1290144d5a004e03b91b76 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Sat, 26 Aug 2017 06:55:34 -0700 Subject: [PATCH] runtime: only clear key string's pointer in mapdelete_faststr Change-Id: I0360d294868ec4423e4ae036009fac4e72425c9c Reviewed-on: https://go-review.googlesource.com/59152 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- src/runtime/hashmap_fast.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/runtime/hashmap_fast.go b/src/runtime/hashmap_fast.go index c378647892..f117311439 100644 --- a/src/runtime/hashmap_fast.go +++ b/src/runtime/hashmap_fast.go @@ -754,7 +754,8 @@ search: if k.str != key.str && !memequal(k.str, key.str, uintptr(key.len)) { continue } - *(*string)(kptr) = "" + // Clear key's pointer. + k.str = nil // Only clear value if there are pointers in it. if t.elem.kind&kindNoPointers == 0 { v := add(unsafe.Pointer(b), dataOffset+bucketCnt*2*sys.PtrSize+i*uintptr(t.valuesize)) -- 2.50.0