]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix crash if user sets MemProfileRate=0
authorDmitriy Vyukov <dvyukov@google.com>
Sun, 16 Oct 2011 07:49:24 +0000 (10:49 +0300)
committerDmitriy Vyukov <dvyukov@google.com>
Sun, 16 Oct 2011 07:49:24 +0000 (10:49 +0300)
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5284044

src/pkg/runtime/malloc.goc

index b7991d03a565b0927689a52c03bcd1f31d7f02f1..2f6f8091274919872da844bf5968783c28845b4d 100644 (file)
@@ -220,7 +220,8 @@ runtime·allocmcache(void)
        rate = runtime·MemProfileRate;
        if(rate > 0x3fffffff)   // make 2*rate not overflow
                rate = 0x3fffffff;
-       c->next_sample = runtime·fastrand1() % (2*rate);
+       if(rate != 0)
+               c->next_sample = runtime·fastrand1() % (2*rate);
 
        return c;
 }