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

[tor-commits] [tor/master] Yet more memory leaks in the rendcache tests



commit 8b01849f3bce1beaf2f08f2c0b94feabda0f5978
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Wed Oct 21 10:54:07 2015 -0400

    Yet more memory leaks in the rendcache tests
---
 src/or/rendcache.c        |    2 +-
 src/or/rendcache.h        |    2 ++
 src/test/test_rendcache.c |    8 +++++++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/or/rendcache.c b/src/or/rendcache.c
index 82c0336..deb2fea 100644
--- a/src/or/rendcache.c
+++ b/src/or/rendcache.c
@@ -157,7 +157,7 @@ rend_cache_failure_entry_free(rend_cache_failure_t *entry)
 
 /** Helper: deallocate a rend_cache_failure_t. (Used with strmap_free(),
  * which requires a function pointer whose argument is void*). */
-static void
+STATIC void
 rend_cache_failure_entry_free_(void *entry)
 {
   rend_cache_failure_entry_free(entry);
diff --git a/src/or/rendcache.h b/src/or/rendcache.h
index a0cb68e..decb040 100644
--- a/src/or/rendcache.h
+++ b/src/or/rendcache.h
@@ -107,6 +107,8 @@ STATIC void cache_failure_intro_add(const uint8_t *identity,
                                     rend_intro_point_failure_t failure);
 STATIC void validate_intro_point_failure(const rend_service_descriptor_t *desc,
                                         const char *service_id);
+
+STATIC void rend_cache_failure_entry_free_(void *entry);
 #endif
 
 #endif /* TOR_RENDCACHE_H */
diff --git a/src/test/test_rendcache.c b/src/test/test_rendcache.c
index 5574d3d..a1c456c 100644
--- a/src/test/test_rendcache.c
+++ b/src/test/test_rendcache.c
@@ -439,6 +439,8 @@ test_rend_cache_lookup_v2_desc_as_dir(void *data)
   NS_UNMOCK(hid_serv_responsible_for_desc_id);
   tor_free(mock_routerinfo);
   rend_cache_free_all();
+  rend_encoded_v2_service_descriptor_free(desc_holder);
+  tor_free(service_id);
 }
 
 #undef NS_SUBMODULE
@@ -594,6 +596,8 @@ test_rend_cache_store_v2_desc_as_dir_with_different_time(void *data)
   SMARTLIST_FOREACH(descs, rend_encoded_v2_service_descriptor_t *, d,
                     rend_encoded_v2_service_descriptor_free(d));
   smartlist_free(descs);
+  rend_encoded_v2_service_descriptor_free(desc_holder_newer);
+  rend_encoded_v2_service_descriptor_free(desc_holder_older);
 }
 
 static void
@@ -1026,6 +1030,7 @@ test_rend_cache_purge(void *data)
   tt_int_op(strmap_size(rend_cache), OP_EQ, 0);
 
   // Deals with existing rend_cache
+  rend_cache_free_all();
   rend_cache_init();
 
   our_rend_cache = rend_cache;
@@ -1229,6 +1234,7 @@ test_rend_cache_failure_purge(void *data)
   (void)data;
 
   // Handles a null failure cache
+  strmap_free(rend_cache_failure, rend_cache_failure_entry_free_);
   rend_cache_failure = NULL;
 
   rend_cache_failure_purge();
@@ -1236,7 +1242,7 @@ test_rend_cache_failure_purge(void *data)
   tt_int_op(strmap_size(rend_cache_failure), OP_EQ, 0);
 
  done:
-  (void)0;
+  rend_cache_free_all();
 }
 
 static void



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