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

[tor-commits] [tor/master] Expose desc_intro_point_free to the tests, and use it.



commit a4291eef5aeeb9ba8939b563a657ac50d4447b7e
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Nov 4 14:21:53 2016 -0400

    Expose desc_intro_point_free to the tests, and use it.
    
    Also fix another couple of leaks.
---
 src/or/hs_descriptor.c        |  2 +-
 src/or/hs_descriptor.h        |  2 +-
 src/test/test_hs_descriptor.c | 12 +++++++++---
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index 946418e..668862f 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -77,7 +77,7 @@ static token_rule_t hs_desc_intro_point_v3_token_table[] = {
 };
 
 /* Free a descriptor intro point object. */
-static void
+STATIC void
 desc_intro_point_free(hs_desc_intro_point_t *ip)
 {
   if (!ip) {
diff --git a/src/or/hs_descriptor.h b/src/or/hs_descriptor.h
index 0c30a52..8bc7256 100644
--- a/src/or/hs_descriptor.h
+++ b/src/or/hs_descriptor.h
@@ -232,7 +232,7 @@ STATIC int cert_is_valid(tor_cert_t *cert, uint8_t type,
 STATIC int desc_sig_is_valid(const char *b64_sig,
                              const ed25519_keypair_t *signing_kp,
                              const char *encoded_desc, size_t encoded_len);
-
+STATIC void desc_intro_point_free(hs_desc_intro_point_t *ip);
 #endif /* HS_DESCRIPTOR_PRIVATE */
 
 #endif /* TOR_HS_DESCRIPTOR_H */
diff --git a/src/test/test_hs_descriptor.c b/src/test/test_hs_descriptor.c
index 01e32cf..846732c 100644
--- a/src/test/test_hs_descriptor.c
+++ b/src/test/test_hs_descriptor.c
@@ -593,7 +593,7 @@ test_decode_intro_point(void *arg)
   int ret;
   char *encoded_ip = NULL;
   size_t len_out;
-  hs_desc_intro_point_t *ip;
+  hs_desc_intro_point_t *ip = NULL;
   hs_descriptor_t *desc = NULL;
 
   (void) arg;
@@ -673,6 +673,8 @@ test_decode_intro_point(void *arg)
     const char *junk = "this is not a descriptor";
     ip = decode_introduction_point(desc, junk);
     tt_assert(!ip);
+    desc_intro_point_free(ip);
+    ip = NULL;
   }
 
   /* Invalid link specifiers. */
@@ -689,6 +691,8 @@ test_decode_intro_point(void *arg)
     tt_assert(!ip);
     tor_free(encoded_ip);
     smartlist_free(lines);
+    desc_intro_point_free(ip);
+    ip = NULL;
   }
 
   /* Invalid auth key type. */
@@ -803,6 +807,7 @@ test_decode_intro_point(void *arg)
 
  done:
   hs_descriptor_free(desc);
+  desc_intro_point_free(ip);
 }
 
 const char encrypted_desc_portion[] = "create2-formats 2\n"
@@ -1027,6 +1032,7 @@ test_validate_cert(void *arg)
   int ret;
   time_t now = time(NULL);
   ed25519_keypair_t kp;
+  tor_cert_t *cert = NULL;
 
   (void) arg;
 
@@ -1034,7 +1040,7 @@ test_validate_cert(void *arg)
   tt_int_op(ret, ==, 0);
 
   /* Cert of type CERT_TYPE_AUTH_HS_IP_KEY. */
-  tor_cert_t *cert = tor_cert_create(&kp, CERT_TYPE_AUTH_HS_IP_KEY,
+  cert = tor_cert_create(&kp, CERT_TYPE_AUTH_HS_IP_KEY,
                                      &kp.pubkey, now, 3600,
                                      CERT_FLAG_INCLUDE_SIGNING_KEY);
   tt_assert(cert);
@@ -1062,7 +1068,7 @@ test_validate_cert(void *arg)
   tt_int_op(ret, OP_EQ, 0);
 
  done:
-  ;
+  tor_cert_free(cert);
 }
 
 static void



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