Backport: Make it possible to call set_onion_key twice without leaking RAM.

svn:r17675
This commit is contained in:
Nick Mathewson 2008-12-18 05:47:34 +00:00
parent 9b72e96f95
commit ca248222bb
1 changed files with 2 additions and 0 deletions

View File

@ -60,6 +60,8 @@ static void
set_onion_key(crypto_pk_env_t *k)
{
tor_mutex_acquire(key_lock);
if (onionkey)
crypto_free_pk_env(onionkey);
onionkey = k;
onionkey_set_at = time(NULL);
tor_mutex_release(key_lock);