]> granicus.if.org Git - pdns/commitdiff
dnsdist: avoid crash when printing nullptr retvals
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Thu, 26 Oct 2017 21:43:37 +0000 (23:43 +0200)
committerChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Thu, 26 Oct 2017 21:49:56 +0000 (23:49 +0200)
pdns/dnsdist-console.cc

index 88ec89867df58b14c58bf2592bac3ed2acb5d686..2ab19c3b03b9d941ae6fd76fa02098272f4e4767 100644 (file)
@@ -215,10 +215,14 @@ void doConsole()
           >(withReturn ? ("return "+line) : line);
         if(ret) {
           if (const auto dsValue = boost::get<shared_ptr<DownstreamState>>(&*ret)) {
-            cout<<(*dsValue)->getName()<<endl;
+            if (*dsValue) {
+              cout<<(*dsValue)->getName()<<endl;
+            }
           }
           else if (const auto csValue = boost::get<ClientState*>(&*ret)) {
-            cout<<(*csValue)->local.toStringWithPort()<<endl;
+            if (*csValue) {
+              cout<<(*csValue)->local.toStringWithPort()<<endl;
+            }
           }
           else if (const auto strValue = boost::get<string>(&*ret)) {
             cout<<*strValue<<endl;
@@ -524,10 +528,18 @@ try
 
       if(ret) {
         if (const auto dsValue = boost::get<shared_ptr<DownstreamState>>(&*ret)) {
-          response=(*dsValue)->getName()+"\n";
+          if (*dsValue) {
+            response=(*dsValue)->getName()+"\n";
+          } else {
+            response="";
+          }
         }
         else if (const auto csValue = boost::get<ClientState*>(&*ret)) {
-          response=(*csValue)->local.toStringWithPort()+"\n";
+          if (*csValue) {
+            response=(*csValue)->local.toStringWithPort()+"\n";
+          } else {
+            response="";
+          }
         }
         else if (const auto strValue = boost::get<string>(&*ret)) {
           response=*strValue+"\n";