aboutsummaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-10-25 07:03:22 +0000
committerNick Mathewson <nickm@torproject.org>2005-10-25 07:03:22 +0000
commit81dd50a942bd7c81b66c6f874466060eeb3cf805 (patch)
tree97b9d716c08432fd0c3d9af58dde179dbcd2dc94 /src/or/directory.c
parent91a666064ab58df284cfa180251e2abf3d9e3481 (diff)
downloadtor-81dd50a942bd7c81b66c6f874466060eeb3cf805.tar.gz
tor-81dd50a942bd7c81b66c6f874466060eeb3cf805.zip
Fix memory leak when retrieving networkstatus or routerdesc by malformed fingerprint
svn:r5307
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 175ddfbc02..af6b9afc49 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1678,21 +1678,23 @@ dir_split_resource_into_fingerprints(const char *resource,
}
if (decode_hex) {
int i;
- char *cp, *d;
+ char *cp, *d = NULL;
for (i = 0; i < smartlist_len(fp_out); ++i) {
cp = smartlist_get(fp_out, i);
if (strlen(cp) != HEX_DIGEST_LEN) {
smartlist_del(fp_out, i--);
- continue;
+ goto again;
}
d = tor_malloc_zero(DIGEST_LEN);
if (base16_decode(d, DIGEST_LEN, cp, HEX_DIGEST_LEN)<0) {
- tor_free(d);
smartlist_del(fp_out, i--);
- continue;
+ goto again;
}
- tor_free(cp);
smartlist_set(fp_out, i, d);
+ d = NULL;
+ again:
+ tor_free(cp);
+ tor_free(d);
}
}
return 0;