From 1135fc397801c04ab68822978d88ee66de48d52c Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Sun, 16 Oct 2011 10:49:24 +0300 Subject: [PATCH] runtime: fix crash if user sets MemProfileRate=0 R=golang-dev, r CC=golang-dev https://golang.org/cl/5284044 --- src/pkg/runtime/malloc.goc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index b7991d03a5..2f6f809127 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -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; }