13
0

Fix an edge-case in Dummy backend's random generator

INT_MAX == 2^31 is not a valid random seed for this LCG.
This commit is contained in:
Robin Gareus 2018-10-22 15:46:39 +02:00
parent 4e1464e70f
commit 4e4c6e7d1e

View File

@ -1664,13 +1664,13 @@ void DummyPort::setup_random_number_generator ()
#ifdef PLATFORM_WINDOWS #ifdef PLATFORM_WINDOWS
LARGE_INTEGER Count; LARGE_INTEGER Count;
if (QueryPerformanceCounter (&Count)) { if (QueryPerformanceCounter (&Count)) {
_rseed = Count.QuadPart % UINT_MAX; _rseed = Count.QuadPart;
} else } else
#endif #endif
{ {
_rseed = g_get_monotonic_time() % UINT_MAX; _rseed = g_get_monotonic_time();
} }
_rseed = (_rseed + (uint64_t)this) % UINT_MAX; _rseed = (_rseed + (uint64_t)this) % INT_MAX;
if (_rseed == 0) _rseed = 1; if (_rseed == 0) _rseed = 1;
} }