From 4f60602bd68da632d91048463b36381630ab8ed6 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 19 Jul 2013 17:44:42 +0000 Subject: [PATCH] Run the random pool setup and teardown functions with random_active nonzero rather than zero. git-svn-id: svn://svn.tartarus.org/sgt/putty@9935 cda61777-01e9-0310-a592-d414129be87e --- sshrand.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sshrand.c b/sshrand.c index 85dfa0b6..797fce73 100644 --- a/sshrand.c +++ b/sshrand.c @@ -213,23 +213,24 @@ void random_ref(void) if (!random_active) { memset(&pool, 0, sizeof(pool)); /* just to start with */ + random_active++; + noise_get_heavy(random_add_heavynoise_bitbybit); random_stir(); next_noise_collection = schedule_timer(NOISE_REGULAR_INTERVAL, random_timer, &pool); } - - random_active++; } void random_unref(void) { + assert(random_active > 0); + if (random_active == 1) { + random_save_seed(); + expire_timer_context(&pool); + } random_active--; - assert(random_active >= 0); - if (random_active) return; - - expire_timer_context(&pool); } int random_byte(void) -- 2.11.0