summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-12-09 08:30:55 -0500
committerNick Mathewson <nickm@torproject.org>2016-12-09 08:30:55 -0500
commita3b8286b0e5ca3415750d6b6813261817893c4da (patch)
tree71f50cee194b9d36cfb5d18d7b66ac2dced8eeae /src/or
parent39f455468731d4746adb729a67597927beaca4b8 (diff)
parent9bb3bcbc414f8845d025e6bf74ffdf6be96a5ebe (diff)
downloadtor-a3b8286b0e5ca3415750d6b6813261817893c4da.tar.gz
tor-a3b8286b0e5ca3415750d6b6813261817893c4da.zip
Merge branch 'maint-0.2.9'
Diffstat (limited to 'src/or')
-rw-r--r--src/or/routerlist.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 9bcca76b63..6bac57d4db 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -3237,6 +3237,17 @@ signed_descriptor_free(signed_descriptor_t *sd)
tor_free(sd);
}
+/** Reset the given signed descriptor <b>sd</b> by freeing the allocated
+ * memory inside the object and by zeroing its content. */
+static void
+signed_descriptor_reset(signed_descriptor_t *sd)
+{
+ tor_assert(sd);
+ tor_free(sd->signed_descriptor_body);
+ tor_cert_free(sd->signing_key_cert);
+ memset(sd, 0, sizeof(*sd));
+}
+
/** Copy src into dest, and steal all references inside src so that when
* we free src, we don't mess up dest. */
static void
@@ -3244,6 +3255,8 @@ signed_descriptor_move(signed_descriptor_t *dest,
signed_descriptor_t *src)
{
tor_assert(dest != src);
+ /* Cleanup destination object before overwriting it.*/
+ signed_descriptor_reset(dest);
memcpy(dest, src, sizeof(signed_descriptor_t));
src->signed_descriptor_body = NULL;
src->signing_key_cert = NULL;