diff options
author | theanarkh <theratliter@gmail.com> | 2022-07-24 08:04:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-24 08:04:54 +0300 |
commit | d63a4cbbd85839ecdfc9ed94364be0a78f261cb8 (patch) | |
tree | f5d1e2c11985d41f3e60980cfe5879202b4e127b /src/cares_wrap.cc | |
parent | 7ef069e483e015a803660125cdbfa81ddfa0357b (diff) |
dns: fix cares memory leak
PR-URL: https://github.com/nodejs/node/pull/43912
Refs: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'src/cares_wrap.cc')
-rw-r--r-- | src/cares_wrap.cc | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 30e27ecf70a..a16a0dcbd1b 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -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(); @@ -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); |