]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix integer overflow in hashmap
authorDmitriy Vyukov <dvyukov@google.com>
Tue, 9 Apr 2013 01:56:38 +0000 (18:56 -0700)
committerDmitriy Vyukov <dvyukov@google.com>
Tue, 9 Apr 2013 01:56:38 +0000 (18:56 -0700)
The test is problematic, because it requires 8GB+ of RAM.
Fixes #5239.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/8550043

src/pkg/runtime/hashmap.c

index 0f32d94e0f4cceceeff2ea0ed0895daf3544b0e7..892f0a1700c06c542385f5ed463cea79863d6b40 100644 (file)
@@ -451,7 +451,7 @@ hash_grow(MapType *t, Hmap *h)
        old_buckets = h->buckets;
        // NOTE: this could be a big malloc, but since we don't need zeroing it is probably fast.
        if(checkgc) mstats.next_gc = mstats.heap_alloc;
-       new_buckets = runtime·mallocgc(h->bucketsize << (h->B + 1), 0, 1, 0);
+       new_buckets = runtime·mallocgc((uintptr)h->bucketsize << (h->B + 1), 0, 1, 0);
        flags = (h->flags & ~(Iterator | OldIterator));
        if((h->flags & Iterator) != 0) {
                flags |= OldIterator;