]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: initialize complete Hiter during mapiterinit
authorRuss Cox <rsc@golang.org>
Thu, 27 Mar 2014 01:52:29 +0000 (21:52 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 27 Mar 2014 01:52:29 +0000 (21:52 -0400)
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

src/pkg/runtime/hashmap.goc

index 4900a16ff4ad501bfa7aeffdcb1a382dd50bdc1e..4f5e78897bc7f9e625cd570fd5660074f74c3aa8 100644 (file)
@@ -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;