Skip to content

Commit 297eca5

Browse files
theanarkhFyko
authored andcommitted
dns: fix cares memory leak
PR-URL: nodejs#43912 Refs: nodejs#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]>
1 parent 69227e1 commit 297eca5

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/cares_wrap.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,7 @@ static void Query(const FunctionCallbackInfo<Value>& args) {
14281428

14291429

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

1491-
uv_freeaddrinfo(res);
1492-
14931492
TRACE_EVENT_NESTABLE_ASYNC_END2(
14941493
TRACING_CATEGORY_NODE2(dns, native), "lookup", req_wrap.get(),
14951494
"count", n, "verbatim", verbatim);

0 commit comments

Comments
 (0)