aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-04-26 12:45:34 -0400
committerNick Mathewson <nickm@torproject.org>2014-04-29 13:00:00 -0400
commit65575b0755f64d21d59532bf58e6c27e14086bbb (patch)
tree40d9d70ad47837ed1da9532a1401d89aeffe901f /src
parentef3d7f2f97caf961effd7935dd3231e6bba62ca5 (diff)
downloadtor-65575b0755f64d21d59532bf58e6c27e14086bbb.tar
tor-65575b0755f64d21d59532bf58e6c27e14086bbb.tar.gz
Stop leaking memory in error cases of md parsing
When clearing a list of tokens, it's important to do token_clear() on them first, or else any keys they contain will leak. This didn't leak memory on any of the successful microdescriptor parsing paths, but it does leak on some failing paths when the failure happens during tokenization. Fixes bug 11618; bugfix on 0.2.2.6-alpha.
Diffstat (limited to 'src')
-rw-r--r--src/or/routerparse.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 97e0bc8c8..3ff887c3c 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -4455,11 +4455,13 @@ microdescs_parse_from_string(const char *s, const char *eos,
microdesc_free(md);
md = NULL;
+ SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));
memarea_clear(area);
smartlist_clear(tokens);
s = start_of_next_microdesc;
}
+ SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));
memarea_drop_all(area);
smartlist_free(tokens);