From 375b7bb76786ad61711771c7703f4c71b4489987 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Fri, 4 Apr 2014 12:58:19 -0700 Subject: [PATCH] cmd/gc: compute size of keys & values before making map bucket Fixes #7547 LGTM=iant R=iant, khr CC=golang-codereviews https://golang.org/cl/84470046 --- src/cmd/gc/reflect.c | 2 ++ test/fixedbugs/issue7547.go | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/fixedbugs/issue7547.go diff --git a/src/cmd/gc/reflect.c b/src/cmd/gc/reflect.c index 3f4734ef528..75d7d8c1c80 100644 --- a/src/cmd/gc/reflect.c +++ b/src/cmd/gc/reflect.c @@ -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 index 00000000000..f75a33036fb --- /dev/null +++ b/test/fixedbugs/issue7547.go @@ -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() +}