]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: compute size of keys & values before making map bucket
authorKeith Randall <khr@golang.org>
Fri, 4 Apr 2014 19:58:19 +0000 (12:58 -0700)
committerKeith Randall <khr@golang.org>
Fri, 4 Apr 2014 19:58:19 +0000 (12:58 -0700)
Fixes #7547

LGTM=iant
R=iant, khr
CC=golang-codereviews
https://golang.org/cl/84470046

src/cmd/gc/reflect.c
test/fixedbugs/issue7547.go [new file with mode: 0644]

index 3f4734ef528324d8f0082eec770a2a036b44d0af..75d7d8c1c80180587a47dfa8dbb6e70ba2b8fdf3 100644 (file)
@@ -125,6 +125,8 @@ mapbucket(Type *t)
 
        keytype = t->down;
        valtype = t->type;
+       dowidth(keytype);
+       dowidth(valtype);
        if(keytype->width > MAXKEYSIZE)
                keytype = ptrto(keytype);
        if(valtype->width > MAXVALSIZE)
diff --git a/test/fixedbugs/issue7547.go b/test/fixedbugs/issue7547.go
new file mode 100644 (file)
index 0000000..f75a330
--- /dev/null
@@ -0,0 +1,17 @@
+// compile
+
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func f() map[string]interface{} {
+       var p *map[string]map[string]interface{}
+       _ = p
+       return nil
+}
+
+func main() {
+       f()
+}