Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: src/base/utils/random-number-generator.cc

Issue 1541143002: Prevent using 0 as random seed. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/utils/random-number-generator.cc
diff --git a/src/base/utils/random-number-generator.cc b/src/base/utils/random-number-generator.cc
index 53a37526714a127f8ad9bf68677e7d88eaae6496..ff428402b6b7c92faf4dab6cb8569458606ade32 100644
--- a/src/base/utils/random-number-generator.cc
+++ b/src/base/utils/random-number-generator.cc
@@ -124,6 +124,7 @@ int RandomNumberGenerator::Next(int bits) {
void RandomNumberGenerator::SetSeed(int64_t seed) {
+ if (seed == 0) seed = 1;
initial_seed_ = seed;
state0_ = MurmurHash3(bit_cast<uint64_t>(seed));
state1_ = MurmurHash3(state0_);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698