aboutsummaryrefslogtreecommitdiff
path: root/src/random.h
diff options
context:
space:
mode:
authorJeremy Rubin <j@rubin.io>2019-10-28 16:42:39 -0700
committerJeremy Rubin <j@rubin.io>2019-10-28 16:42:39 -0700
commita35b6824f3a0bdb68c5aef599c0f17562689970e (patch)
tree05072617dfd5744371e411931cfce6a6a8bf3450 /src/random.h
parent4c1090c882ea15ba4d10a2f7f320f3c0eb490ebd (diff)
downloadbitcoin-a35b6824f3a0bdb68c5aef599c0f17562689970e.tar.xz
Add assertion to randrange that input is not 0
Diffstat (limited to 'src/random.h')
-rw-r--r--src/random.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/random.h b/src/random.h
index 22801ec155..9d1f751773 100644
--- a/src/random.h
+++ b/src/random.h
@@ -166,6 +166,7 @@ public:
/** Generate a random integer in the range [0..range). */
uint64_t randrange(uint64_t range) noexcept
{
+ assert(range);
--range;
int bits = CountBits(range);
while (true) {