浏览代码

Make it possible to call set_onion_key twice without leaking RAM.

svn:r17673
Nick Mathewson 15 年之前
父节点
当前提交
1b735e46dd
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      src/or/router.c

+ 4 - 2
src/or/router.c

@@ -53,13 +53,15 @@ static authority_cert_t *legacy_key_certificate = NULL;
  * 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);