Skip to content

Commit

Permalink
dns: fix cares memory leak
Browse files Browse the repository at this point in the history
PR-URL: #43912
Refs: #39735
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
theanarkh authored and targos committed Aug 1, 2022
1 parent 19397a0 commit 43a3239
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,7 @@ static void Query(const FunctionCallbackInfo<Value>& args) {


void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
auto cleanup = OnScopeLeave([&]() { uv_freeaddrinfo(res); });
std::unique_ptr<GetAddrInfoReqWrap> req_wrap {
static_cast<GetAddrInfoReqWrap*>(req->data)};
Environment* env = req_wrap->env();
Expand Down Expand Up @@ -1488,8 +1489,6 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
argv[1] = results;
}

uv_freeaddrinfo(res);

TRACE_EVENT_NESTABLE_ASYNC_END2(
TRACING_CATEGORY_NODE2(dns, native), "lookup", req_wrap.get(),
"count", n, "verbatim", verbatim);
Expand Down

0 comments on commit 43a3239

Please sign in to comment.