diff options
author | Brian Silverman <bsilver16384@gmail.com> | 2016-03-01 17:55:53 -0500 |
---|---|---|
committer | Brian Silverman <bsilver16384@gmail.com> | 2016-03-01 17:59:08 -0500 |
commit | 22123a37c236e26535d3f3fff7f31a5b6515d7d6 (patch) | |
tree | b39784d13b162bcfc203bbe71f2b2d9503a49af8 | |
parent | 66e1e94f38467b5c7bbfb05e3c7267f3039a2c69 (diff) | |
download | gperftools-22123a37c236e26535d3f3fff7f31a5b6515d7d6.tar.gz |
Don't overflow a signed integer
It's undefined behavior and ubsan catches it.
-rw-r--r-- | src/base/low_level_alloc.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/base/low_level_alloc.cc b/src/base/low_level_alloc.cc index 172bc8d..6b467cf 100644 --- a/src/base/low_level_alloc.cc +++ b/src/base/low_level_alloc.cc @@ -107,7 +107,7 @@ static int IntLog2(size_t size, size_t base) { // Return a random integer n: p(n)=1/(2**n) if 1 <= n; p(n)=0 if n < 1. static int Random() { - static int32 r = 1; // no locking---it's not critical + static uint32 r = 1; // no locking---it's not critical ANNOTATE_BENIGN_RACE(&r, "benign race, not critical."); int result = 1; while ((((r = r*1103515245 + 12345) >> 30) & 1) == 0) { |