From: Russ Cox Date: Thu, 27 Mar 2014 01:52:29 +0000 (-0400) Subject: runtime: initialize complete Hiter during mapiterinit X-Git-Tag: go1.3beta1~256 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=fc6befba3c2a076f34fd4225cf76a7e8639ac100;p=gostls13.git runtime: initialize complete Hiter during mapiterinit The garbage collector will scan these pointers, so make sure they are initialized. LGTM=bradfitz, khr R=khr, bradfitz CC=golang-codereviews https://golang.org/cl/80960047 --- diff --git a/src/pkg/runtime/hashmap.goc b/src/pkg/runtime/hashmap.goc index 4900a16ff4..4f5e78897b 100644 --- a/src/pkg/runtime/hashmap.goc +++ b/src/pkg/runtime/hashmap.goc @@ -1004,6 +1004,14 @@ func reflect·mapdelete(t *MapType, h *Hmap, key *byte) { #pragma textflag NOSPLIT func mapiterinit(t *MapType, h *Hmap, it *Hiter) { + // Clear pointer fields so garbage collector does not complain. + it->key = nil; + it->value = nil; + it->t = nil; + it->h = nil; + it->buckets = nil; + it->bptr = nil; + if(h == nil || h->count == 0) { it->key = nil; return;