[gmime] Moved srand() initialization to g_mime_init()
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime] Moved srand() initialization to g_mime_init()
- Date: Tue, 27 Sep 2016 13:51:57 +0000 (UTC)
commit 423ccbeabcd8264b51806e38a83012ec8606120b
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date: Tue Sep 27 09:51:35 2016 -0400
Moved srand() initialization to g_mime_init()
Fixes bug #770634
gmime/gmime-multipart.c | 6 ------
gmime/gmime.c | 4 ++++
2 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/gmime/gmime-multipart.c b/gmime/gmime-multipart.c
index fde17d0..b17197e 100644
--- a/gmime/gmime-multipart.c
+++ b/gmime/gmime-multipart.c
@@ -708,14 +708,8 @@ read_random_pool (unsigned char *buffer, size_t bytes)
close (fd);
#else
- static gboolean srand_initialized = FALSE;
size_t i;
- if (!srand_initialized) {
- srand ((unsigned int) time (NULL));
- srand_initialized = TRUE;
- }
-
for (i = 0; i < bytes; i++)
buffer[i] = (unsigned char) (rand () % 256);
#endif
diff --git a/gmime/gmime.c b/gmime/gmime.c
index d8c2fa6..5174581 100644
--- a/gmime/gmime.c
+++ b/gmime/gmime.c
@@ -23,6 +23,7 @@
#include <config.h>
#endif
+#include <stdlib.h>
#include <time.h>
#ifdef ENABLE_SMIME
@@ -120,6 +121,9 @@ g_mime_init (guint32 flags)
{
if (initialized++)
return;
+
+ /* seed the random number generator (needed by boundary generator) */
+ srand ((unsigned int) time (NULL));
#if defined (HAVE_TIMEZONE) || defined (HAVE__TIMEZONE)
/* initialize timezone */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]