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

[tor-commits] [tor/release-0.4.6] Merge branch 'maint-0.4.5' into maint-0.4.6



commit f0260c4cea6da784369e8d47f0b4bf01863c5af5
Merge: 38bfb3cdfe 8c29729916
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Fri Apr 23 13:00:23 2021 +0300

    Merge branch 'maint-0.4.5' into maint-0.4.6

 changes/ticket40356       |  3 +++
 src/feature/hs/hs_cache.c | 61 ++++++++++++++++++++++++++++-------------------
 2 files changed, 39 insertions(+), 25 deletions(-)

diff --cc src/feature/hs/hs_cache.c
index bb1532f808,9c35936748..cf8e377313
--- a/src/feature/hs/hs_cache.c
+++ b/src/feature/hs/hs_cache.c
@@@ -390,10 -415,21 +415,21 @@@ remove_v3_desc_as_client(const hs_cache
  static void
  store_v3_desc_as_client(hs_cache_client_descriptor_t *desc)
  {
+   hs_cache_client_descriptor_t *cached_desc;
+ 
    tor_assert(desc);
+ 
+   /* Because the lookup function doesn't return an expired entry, it can linger
+    * in the cache until we clean it up or a new descriptor is stored. So,
+    * before adding, we'll make sure we are not overwriting an old descriptor
+    * (which is OK in terms of semantic) but leads to memory leak. */
+   cached_desc = digest256map_get(hs_cache_v3_client, desc->key.pubkey);
+   if (cached_desc) {
+     cache_client_desc_free(cached_desc);
+   }
    digest256map_set(hs_cache_v3_client, desc->key.pubkey, desc);
    /* Update cache size with this entry for the OOM handler. */
 -  rend_cache_increment_allocation(cache_get_client_entry_size(desc));
 +  hs_cache_increment_allocation(cache_get_client_entry_size(desc));
  }
  
  /** Query our cache and return the entry or NULL if not found or if expired. */

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