Yet more memory leaks in the rendcache tests

This commit is contained in:
Nick Mathewson 2015-10-21 10:54:07 -04:00
parent a5e873ff29
commit 8b01849f3b
3 changed files with 10 additions and 2 deletions

View File

@ -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(), /** Helper: deallocate a rend_cache_failure_t. (Used with strmap_free(),
* which requires a function pointer whose argument is void*). */ * 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_(void *entry)
{ {
rend_cache_failure_entry_free(entry); rend_cache_failure_entry_free(entry);

View File

@ -107,6 +107,8 @@ STATIC void cache_failure_intro_add(const uint8_t *identity,
rend_intro_point_failure_t failure); rend_intro_point_failure_t failure);
STATIC void validate_intro_point_failure(const rend_service_descriptor_t *desc, STATIC void validate_intro_point_failure(const rend_service_descriptor_t *desc,
const char *service_id); const char *service_id);
STATIC void rend_cache_failure_entry_free_(void *entry);
#endif #endif
#endif /* TOR_RENDCACHE_H */ #endif /* TOR_RENDCACHE_H */

View File

@ -439,6 +439,8 @@ test_rend_cache_lookup_v2_desc_as_dir(void *data)
NS_UNMOCK(hid_serv_responsible_for_desc_id); NS_UNMOCK(hid_serv_responsible_for_desc_id);
tor_free(mock_routerinfo); tor_free(mock_routerinfo);
rend_cache_free_all(); rend_cache_free_all();
rend_encoded_v2_service_descriptor_free(desc_holder);
tor_free(service_id);
} }
#undef NS_SUBMODULE #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, SMARTLIST_FOREACH(descs, rend_encoded_v2_service_descriptor_t *, d,
rend_encoded_v2_service_descriptor_free(d)); rend_encoded_v2_service_descriptor_free(d));
smartlist_free(descs); smartlist_free(descs);
rend_encoded_v2_service_descriptor_free(desc_holder_newer);
rend_encoded_v2_service_descriptor_free(desc_holder_older);
} }
static void static void
@ -1026,6 +1030,7 @@ test_rend_cache_purge(void *data)
tt_int_op(strmap_size(rend_cache), OP_EQ, 0); tt_int_op(strmap_size(rend_cache), OP_EQ, 0);
// Deals with existing rend_cache // Deals with existing rend_cache
rend_cache_free_all();
rend_cache_init(); rend_cache_init();
our_rend_cache = rend_cache; our_rend_cache = rend_cache;
@ -1229,6 +1234,7 @@ test_rend_cache_failure_purge(void *data)
(void)data; (void)data;
// Handles a null failure cache // Handles a null failure cache
strmap_free(rend_cache_failure, rend_cache_failure_entry_free_);
rend_cache_failure = NULL; rend_cache_failure = NULL;
rend_cache_failure_purge(); 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); tt_int_op(strmap_size(rend_cache_failure), OP_EQ, 0);
done: done:
(void)0; rend_cache_free_all();
} }
static void static void