From 6d54c50c707b733b82ffd773a3619240f97687de Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Thu, 26 Oct 2017 23:43:37 +0200 Subject: [PATCH] dnsdist: avoid crash when printing nullptr retvals --- pdns/dnsdist-console.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index 88ec89867d..2ab19c3b03 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -215,10 +215,14 @@ void doConsole() >(withReturn ? ("return "+line) : line); if(ret) { if (const auto dsValue = boost::get>(&*ret)) { - cout<<(*dsValue)->getName()<getName()<(&*ret)) { - cout<<(*csValue)->local.toStringWithPort()<local.toStringWithPort()<(&*ret)) { cout<<*strValue<>(&*ret)) { - response=(*dsValue)->getName()+"\n"; + if (*dsValue) { + response=(*dsValue)->getName()+"\n"; + } else { + response=""; + } } else if (const auto csValue = boost::get(&*ret)) { - response=(*csValue)->local.toStringWithPort()+"\n"; + if (*csValue) { + response=(*csValue)->local.toStringWithPort()+"\n"; + } else { + response=""; + } } else if (const auto strValue = boost::get(&*ret)) { response=*strValue+"\n"; -- 2.47.2