summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/src/utils.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mir_core/src/utils.cpp b/src/mir_core/src/utils.cpp
index e2dea519ab..7b26bb6aab 100644
--- a/src/mir_core/src/utils.cpp
+++ b/src/mir_core/src/utils.cpp
@@ -524,8 +524,15 @@ PGENRANDOM pfnRtlGenRandom;
MIR_CORE_DLL(void) Utils_GetRandom(void *pszDest, size_t cbLen)
{
- if (pszDest != 0 || cbLen != 0 && pfnRtlGenRandom != NULL)
+ if (pszDest == nullptr || cbLen == 0)
+ return;
+
+ if (pfnRtlGenRandom != NULL)
pfnRtlGenRandom(pszDest, (ULONG)cbLen);
- else
- memset(pszDest, 0, cbLen);
+ else {
+ srand(time(NULL));
+ BYTE *p = (BYTE*)pszDest;
+ for (size_t i = 0; i < cbLen; i++)
+ p[i] = rand() & 0xFF;
+ }
}