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

[tor-commits] [tor/master] Fix a few more memory leaks; not in any released Tor



commit f61088ce2321be7c408b4298258a268a0a546e78
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue May 5 11:08:05 2015 -0400

    Fix a few more memory leaks; not in any released Tor
---
 src/or/control.c           |    7 ++++++-
 src/test/test_controller.c |    2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/or/control.c b/src/or/control.c
index ebe3859..780dea5 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -3779,12 +3779,17 @@ add_onion_helper_keyarg(const char *arg, int discard_pk,
     memwipe(cp, 0, strlen(cp));
     tor_free(cp);
   });
+  smartlist_free(key_args);
 
   if (!ok) {
     crypto_pk_free(pk);
     pk = NULL;
   }
-  if (err_msg_out) *err_msg_out = err_msg;
+  if (err_msg_out) {
+    *err_msg_out = err_msg;
+  } else {
+    tor_free(err_msg);
+  }
   *key_new_alg_out = key_new_alg;
   *key_new_blob_out = key_new_blob;
 
diff --git a/src/test/test_controller.c b/src/test/test_controller.c
index 9039dc7..b40825b 100644
--- a/src/test/test_controller.c
+++ b/src/test/test_controller.c
@@ -72,6 +72,7 @@ test_add_onion_helper_keyarg(void *arg)
 
   /* Test loading a invalid key type. */
   tor_free(arg_str);
+  crypto_pk_free(pk); pk = NULL;
   tor_asprintf(&arg_str, "RSA512:%s", encoded);
   pk = add_onion_helper_keyarg(arg_str, 0, &key_new_alg, &key_new_blob,
                                &err_msg);
@@ -82,6 +83,7 @@ test_add_onion_helper_keyarg(void *arg)
 
   /* Test loading a invalid key. */
   tor_free(arg_str);
+  crypto_pk_free(pk); pk = NULL;
   tor_free(err_msg);
   encoded[strlen(encoded)/2] = '\0';
   tor_asprintf(&arg_str, "RSA1024:%s", encoded);

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits