1
0
mirror of https://github.com/golang/go synced 2024-09-30 22:18:32 -06:00

runtime: fix crash if user sets MemProfileRate=0

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5284044
This commit is contained in:
Dmitriy Vyukov 2011-10-16 10:49:24 +03:00
parent fc61ea3ba3
commit 1135fc3978

View 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;
}