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 <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
  • Loading branch information
theanarkh authored and danielleadams committed Jul 26, 2022
1 parent efd5e0e commit 7c75539
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 7c75539

Please sign in to comment.