[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r17673: {tor} Make it possible to call set_onion_key twice without leaking (tor/trunk/src/or)



Author: nickm
Date: 2008-12-18 00:40:57 -0500 (Thu, 18 Dec 2008)
New Revision: 17673

Modified:
   tor/trunk/src/or/router.c
Log:
Make it possible to call set_onion_key twice without leaking RAM.

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2008-12-18 05:28:27 UTC (rev 17672)
+++ tor/trunk/src/or/router.c	2008-12-18 05:40:57 UTC (rev 17673)
@@ -53,13 +53,15 @@
  * used by tor-gencert to sign new signing keys and make new key
  * certificates. */
 
-/** Replace the current onion key with <b>k</b>.  Does not affect lastonionkey;
- * to update onionkey correctly, call rotate_onion_key().
+/** Replace the current onion key with <b>k</b>.  Does not affect
+ * lastonionkey; to update lastonionkey correctly, call rotate_onion_key().
  */
 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);