]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: verify hmap type size
authorDmitriy Vyukov <dvyukov@google.com>
Tue, 29 Jul 2014 18:06:20 +0000 (22:06 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Tue, 29 Jul 2014 18:06:20 +0000 (22:06 +0400)
LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, khr
https://golang.org/cl/114510044

src/pkg/runtime/hashmap.go

index e15033797ca6ac825f675181ad5506a11881e9d1..68ad37c901b6aa33c03909c287cbbb8cdeb0ca60 100644 (file)
@@ -153,8 +153,8 @@ func evacuated(b *bmap) bool {
 }
 
 func makemap(t *maptype, hint int64) *hmap {
-       if unsafe.Sizeof(hmap{}) > 48 {
-               gothrow("hmap too large")
+       if sz := unsafe.Sizeof(hmap{}); sz > 48 || sz != uintptr(t.hmap.size) {
+               gothrow("bad hmap size")
        }
 
        if hint < 0 || int64(int32(hint)) != hint {