[tor-commits] [tor/master] Fix a couple of small memory leaks on failure cases.

nickm at torproject.org nickm at torproject.org
Wed Sep 3 15:02:35 UTC 2014


commit ed8f020e205267e6270494634346ab68d830e1d8
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Sep 3 10:59:39 2014 -0400

    Fix a couple of small memory leaks on failure cases.
    
    [CID 1234702, 1234703]
---
 src/or/control.c   |    4 ++++
 src/or/microdesc.c |    1 +
 2 files changed, 5 insertions(+)

diff --git a/src/or/control.c b/src/or/control.c
index 053c00b..cd2df5a 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1201,6 +1201,10 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
   tor_free(password);
   connection_printf_to_buf(conn, "515 Authentication failed: %s\r\n", errstr);
   connection_mark_for_close(TO_CONN(conn));
+  if (sl) { /* clean up */
+    SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+    smartlist_free(sl);
+  }
   return 0;
  ok:
   log_info(LD_CONTROL, "Authenticated control connection ("TOR_SOCKET_T_FORMAT
diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index ed586f3..576fed0 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -576,6 +576,7 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force)
         microdesc_wipe_body(md);
       }
     }
+    smartlist_free(wrote);
     return -1;
   }
 



More information about the tor-commits mailing list