diff --git a/random/rndjent.c b/random/rndjent.c index 0468c7cb..3fefb539 100644 --- a/random/rndjent.c +++ b/random/rndjent.c @@ -290,13 +290,16 @@ _gcry_rndjent_poll (void (*add)(const void*, size_t, enum random_origins), if (!jent_rng_is_initialized) { /* Auto-initialize. */ - jent_rng_is_initialized = 1; jent_entropy_collector_free (jent_rng_collector); jent_rng_collector = NULL; if ( !(_gcry_random_read_conf () & RANDOM_CONF_DISABLE_JENT)) { if (!jent_entropy_init ()) - jent_rng_collector = jent_entropy_collector_alloc (1, 0); + { + jent_rng_collector = jent_entropy_collector_alloc (1, 0); + if (jent_rng_collector != NULL) + jent_rng_is_initialized = 1; + } } } @@ -402,6 +405,7 @@ _gcry_rndjent_fini (void) { jent_entropy_collector_free (jent_rng_collector); jent_rng_collector = NULL; + jent_rng_is_initialized = 0; } unlock_rng ();