summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2018-06-23 10:48:42 +0200
committerAlexander Færøy <ahf@torproject.org>2018-06-23 13:07:56 +0200
commit8e805bf0f65ffd137a6c9ed89be060e5d9ba317d (patch)
tree672edeacaf254da85317c494cd496d05a2a5564e
parentce5d055ed7e4d8e5d1c0b0b922738c87b6a8da1c (diff)
downloadtor-8e805bf0f65ffd137a6c9ed89be060e5d9ba317d.tar.gz
tor-8e805bf0f65ffd137a6c9ed89be060e5d9ba317d.zip
Fix memory leak in new_establish_intro_cell().
This patch fixes a memory leak in new_establish_intro_cell() that could happen if a test assertion fails and the *cell_out value isn't properly free'd. See: Coverity CID 1437445
-rw-r--r--src/test/test_hs_intropoint.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/test_hs_intropoint.c b/src/test/test_hs_intropoint.c
index 0cae2de7e1..b2d2700f8b 100644
--- a/src/test/test_hs_intropoint.c
+++ b/src/test/test_hs_intropoint.c
@@ -43,6 +43,10 @@ new_establish_intro_cell(const char *circ_nonce,
trn_cell_establish_intro_t *cell = NULL;
hs_service_intro_point_t *ip = NULL;
+ /* Ensure that *cell_out is NULL such that we can use to check if we need to
+ * free `cell` in case of an error. */
+ *cell_out = NULL;
+
/* Auth key pair is generated in the constructor so we are all set for
* using this IP object. */
ip = service_intro_point_new(NULL, 0);
@@ -56,6 +60,9 @@ new_establish_intro_cell(const char *circ_nonce,
*cell_out = cell;
done:
+ if (*cell_out == NULL)
+ trn_cell_establish_intro_free(cell);
+
service_intro_point_free(ip);
return cell_len;
}