Skip to content

Commit

Permalink
tests: net: socket: getaddrinfo: fix resource leak
Browse files Browse the repository at this point in the history
Fix resource leak detected by coverity by adding missing
zsock_freeaddrinfo(res) calls.

Coverity-CID: 219527
Fixes #32919

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
  • Loading branch information
gudnimg authored and jukkar committed Mar 19, 2021
1 parent 9b84921 commit 01252c2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/net/socket/getaddrinfo/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ static void test_getaddrinfo_ipv4_hints_ipv6(void)
ret = zsock_getaddrinfo("192.0.2.1", NULL, &hints, &res);
zassert_equal(ret, DNS_EAI_ADDRFAMILY, "Invalid result (%d)", ret);
zassert_is_null(res, "");
zsock_freeaddrinfo(res);
}

static void test_getaddrinfo_ipv6_hints_ipv4(void)
Expand All @@ -576,6 +577,7 @@ static void test_getaddrinfo_ipv6_hints_ipv4(void)
ret = zsock_getaddrinfo("2001:db8::1", NULL, &hints, &res);
zassert_equal(ret, DNS_EAI_ADDRFAMILY, "Invalid result (%d)", ret);
zassert_is_null(res, "");
zsock_freeaddrinfo(res);
}

static void test_getaddrinfo_port_invalid(void)
Expand All @@ -585,6 +587,7 @@ static void test_getaddrinfo_port_invalid(void)
ret = zsock_getaddrinfo("192.0.2.1", "70000", NULL, &res);
zassert_equal(ret, DNS_EAI_NONAME, "Invalid result (%d)", ret);
zassert_is_null(res, "");
zsock_freeaddrinfo(res);
}

static void test_getaddrinfo_null_host(void)
Expand Down

0 comments on commit 01252c2

Please sign in to comment.