diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 30e27ecf70a837..98d796d8b3f26c 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -1473,11 +1473,16 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { return Just(true); }; - if (add(true, verbatim).IsNothing()) + if (add(true, verbatim).IsNothing()) { + uv_freeaddrinfo(res); return; + } + if (verbatim == false) { - if (add(false, true).IsNothing()) + if (add(false, true).IsNothing()) { + uv_freeaddrinfo(res); return; + } } // No responses were found to return