git: 88910b8b7b14 - main - cap_net: plug memory leak
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 14 Dec 2021 11:02:56 UTC
The branch main has been updated by oshogbo:
URL: https://cgit.FreeBSD.org/src/commit/?id=88910b8b7b14386e05bccda0317ace2bfd383ef5
commit 88910b8b7b14386e05bccda0317ace2bfd383ef5
Author: Mariusz Zaborski <oshogbo@FreeBSD.org>
AuthorDate: 2021-12-14 10:57:36 +0000
Commit: Mariusz Zaborski <oshogbo@FreeBSD.org>
CommitDate: 2021-12-14 11:02:40 +0000
cap_net: plug memory leak
MFC after: 5 days
---
lib/libcasper/services/cap_net/cap_net.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/libcasper/services/cap_net/cap_net.c b/lib/libcasper/services/cap_net/cap_net.c
index 1d5531676268..5e10714e3614 100644
--- a/lib/libcasper/services/cap_net/cap_net.c
+++ b/lib/libcasper/services/cap_net/cap_net.c
@@ -326,8 +326,10 @@ cap_getaddrinfo(cap_channel_t *chan, const char *hostname, const char *servname,
break;
nvlai = nvlist_get_nvlist(nvl, nvlname);
curai = addrinfo_unpack(nvlai);
- if (curai == NULL)
+ if (curai == NULL) {
+ nvlist_destroy(nvl);
return (EAI_MEMORY);
+ }
if (prevai != NULL)
prevai->ai_next = curai;
else
@@ -896,8 +898,10 @@ net_getnameinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
error = EAI_FAIL;
goto out;
}
- if (!net_allowed_bsaddr(funclimit, sabin, sabinsize))
- return (ENOTCAPABLE);
+ if (!net_allowed_bsaddr(funclimit, sabin, sabinsize)) {
+ error = ENOTCAPABLE;
+ goto out;
+ }
memcpy(&sast, sabin, sabinsize);
salen = (socklen_t)sabinsize;