]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Rearrange; to avoid uninitialized var and bail out after exception,
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 3 Apr 2019 14:00:12 +0000 (16:00 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 3 Apr 2019 14:00:12 +0000 (16:00 +0200)
b might be inconsistent in that case.

pdns/communicator.hh

index 2cb0f70feb3c5e8ed22777f62d96fce8c6421f2d..831b2cecf534bbd6c16cfe4e72e7b4b08c6808d9 100644 (file)
@@ -258,26 +258,25 @@ public:
     this->resolve_name(&addresses, name);
     
     if(b) {
-        b->lookup(QType(QType::ANY),name);
-        bool ok;
-        do {
+      b->lookup(QType(QType::ANY),name);
+      while (true) {
+        try {
           DNSZoneRecord rr;
-          try {
-            ok = b->get(rr);
-          }
-          catch (PDNSException &ae) {
-            g_log << Logger::Error << "Skipping record: " << ae.reason << endl;
-            continue;
-          }
-          catch (std::exception &e) {
-            g_log << Logger::Error << "Skipping record: " << e.what() << endl;
-            continue;
-          }
-          if (ok) {
-            if (rr.dr.d_type == QType::A || rr.dr.d_type == QType::AAAA)
-              addresses.push_back(rr.dr.d_content->getZoneRepresentation());   // SOL if you have a CNAME for an NS
-          }
-        } while (ok);
+          if (!b->get(rr))
+            break;
+          if (rr.dr.d_type == QType::A || rr.dr.d_type == QType::AAAA)
+            addresses.push_back(rr.dr.d_content->getZoneRepresentation());   // SOL if you have a CNAME for an NS
+        }
+        // After an exception, b can be inconsistent so break
+        catch (PDNSException &ae) {
+          g_log << Logger::Error << "Skipping record(s): " << ae.reason << endl;
+          break;
+        }
+        catch (std::exception &e) {
+          g_log << Logger::Error << "Skipping record(s): " << e.what() << endl;
+          break;
+        }
+      }
     }
     return addresses;
   }