Skip to content

Commit 9f9c703

Browse files
committed
[DHT] Fix RandomIntegerRange when min equals max
1 parent 8c36924 commit 9f9c703

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/util.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@ std::string GenerateRandomString(unsigned int len) {
600600

601601
unsigned int RandomIntegerRange(unsigned int nMin, unsigned int nMax)
602602
{
603+
if (nMin == nMax)
604+
return nMax;
605+
603606
srand(time(NULL) + nMax); //seed srand before using
604607
return nMin + rand() % (nMax - nMin) + 1;
605608
}

0 commit comments

Comments
 (0)