mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 07:07:52 +01:00
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
This commit is contained in:
parent
ce5d055ed7
commit
8e805bf0f6
1 changed files with 7 additions and 0 deletions
|
@ -43,6 +43,10 @@ new_establish_intro_cell(const char *circ_nonce,
|
||||||
trn_cell_establish_intro_t *cell = NULL;
|
trn_cell_establish_intro_t *cell = NULL;
|
||||||
hs_service_intro_point_t *ip = 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
|
/* Auth key pair is generated in the constructor so we are all set for
|
||||||
* using this IP object. */
|
* using this IP object. */
|
||||||
ip = service_intro_point_new(NULL, 0);
|
ip = service_intro_point_new(NULL, 0);
|
||||||
|
@ -56,6 +60,9 @@ new_establish_intro_cell(const char *circ_nonce,
|
||||||
*cell_out = cell;
|
*cell_out = cell;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
if (*cell_out == NULL)
|
||||||
|
trn_cell_establish_intro_free(cell);
|
||||||
|
|
||||||
service_intro_point_free(ip);
|
service_intro_point_free(ip);
|
||||||
return cell_len;
|
return cell_len;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue