aboutsummaryrefslogtreecommitdiff
path: root/src/leveldb/util/random.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2013-08-24 22:21:41 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2013-08-24 22:21:41 +0200
commit877b5e3653f12882e12c75aa0bb5be47f847bd09 (patch)
tree399b43ec4298fdefe16fd9c33e684b3e58867755 /src/leveldb/util/random.h
parente9e2ef5fbd610fbaa3801440254c39ac4ba8f91d (diff)
parenteed29f0f50806b9cfe9653509e7ed7f7eebdd3e3 (diff)
Merge src/leveldb changes for LevelDB 1.13
Diffstat (limited to 'src/leveldb/util/random.h')
-rw-r--r--src/leveldb/util/random.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/leveldb/util/random.h b/src/leveldb/util/random.h
index 07538242ea..ddd51b1c7b 100644
--- a/src/leveldb/util/random.h
+++ b/src/leveldb/util/random.h
@@ -16,7 +16,12 @@ class Random {
private:
uint32_t seed_;
public:
- explicit Random(uint32_t s) : seed_(s & 0x7fffffffu) { }
+ explicit Random(uint32_t s) : seed_(s & 0x7fffffffu) {
+ // Avoid bad seeds.
+ if (seed_ == 0 || seed_ == 2147483647L) {
+ seed_ = 1;
+ }
+ }
uint32_t Next() {
static const uint32_t M = 2147483647L; // 2^31-1
static const uint64_t A = 16807; // bits 14, 8, 7, 5, 2, 1, 0