mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 07:07:52 +01:00
Fix memory link in test_link_specifier().
This patch fixes a memory leak in test_link_specifier() where ls might not get freed in case one of the test macros fails. See: Coverity CID 1437434.
This commit is contained in:
parent
3d80c086be
commit
c997d49ad6
1 changed files with 5 additions and 6 deletions
|
@ -376,6 +376,9 @@ test_link_specifier(void *arg)
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
hs_desc_link_specifier_t spec;
|
hs_desc_link_specifier_t spec;
|
||||||
smartlist_t *link_specifiers = smartlist_new();
|
smartlist_t *link_specifiers = smartlist_new();
|
||||||
|
char buf[256];
|
||||||
|
char *b64 = NULL;
|
||||||
|
link_specifier_t *ls = NULL;
|
||||||
|
|
||||||
(void) arg;
|
(void) arg;
|
||||||
|
|
||||||
|
@ -385,9 +388,7 @@ test_link_specifier(void *arg)
|
||||||
|
|
||||||
/* Test IPv4 for starter. */
|
/* Test IPv4 for starter. */
|
||||||
{
|
{
|
||||||
char *b64, buf[256];
|
|
||||||
uint32_t ipv4;
|
uint32_t ipv4;
|
||||||
link_specifier_t *ls;
|
|
||||||
|
|
||||||
spec.type = LS_IPV4;
|
spec.type = LS_IPV4;
|
||||||
ret = tor_addr_parse(&spec.u.ap.addr, "1.2.3.4");
|
ret = tor_addr_parse(&spec.u.ap.addr, "1.2.3.4");
|
||||||
|
@ -414,9 +415,7 @@ test_link_specifier(void *arg)
|
||||||
|
|
||||||
/* Test IPv6. */
|
/* Test IPv6. */
|
||||||
{
|
{
|
||||||
char *b64, buf[256];
|
|
||||||
uint8_t ipv6[16];
|
uint8_t ipv6[16];
|
||||||
link_specifier_t *ls;
|
|
||||||
|
|
||||||
spec.type = LS_IPV6;
|
spec.type = LS_IPV6;
|
||||||
ret = tor_addr_parse(&spec.u.ap.addr, "[1:2:3:4::]");
|
ret = tor_addr_parse(&spec.u.ap.addr, "[1:2:3:4::]");
|
||||||
|
@ -445,9 +444,7 @@ test_link_specifier(void *arg)
|
||||||
|
|
||||||
/* Test legacy. */
|
/* Test legacy. */
|
||||||
{
|
{
|
||||||
char *b64, buf[256];
|
|
||||||
uint8_t *id;
|
uint8_t *id;
|
||||||
link_specifier_t *ls;
|
|
||||||
|
|
||||||
spec.type = LS_LEGACY_ID;
|
spec.type = LS_LEGACY_ID;
|
||||||
memset(spec.u.legacy_id, 'Y', sizeof(spec.u.legacy_id));
|
memset(spec.u.legacy_id, 'Y', sizeof(spec.u.legacy_id));
|
||||||
|
@ -473,6 +470,8 @@ test_link_specifier(void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
link_specifier_free(ls);
|
||||||
|
tor_free(b64);
|
||||||
smartlist_free(link_specifiers);
|
smartlist_free(link_specifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue