From 1cd0a36f6e746ea6bf6090c87a3968fb37db67af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20No=C3=A9?= Date: Wed, 17 Jul 2019 09:30:19 -0400 Subject: [PATCH] ares-test.cc: Handle nullptr in AddrInfo ostream. (#268) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The const AddrInfo& argument to operator<< overload for AddrInfo can be a nullptr unique_ptr. Handle this explicitly by printing {nullptr} if the rest of the function cannot be safely executed. Fix-by: Dan NoƩ --- test/ares-test.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/ares-test.cc b/test/ares-test.cc index 2df72c92..ec4b4605 100644 --- a/test/ares-test.cc +++ b/test/ares-test.cc @@ -578,6 +578,11 @@ std::ostream& operator<<(std::ostream& os, const AddrInfoResult& result) { std::ostream& operator<<(std::ostream& os, const AddrInfo& ai) { os << '{'; + if (ai == nullptr) { + os << "nullptr}"; + return os; + } + struct ares_addrinfo_cname *next_cname = ai->cnames; while(next_cname) { if(next_cname->alias) {