]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Don't leak on exception and another case that needs an annotation
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 29 Apr 2022 09:42:48 +0000 (11:42 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 29 Apr 2022 09:42:48 +0000 (11:42 +0200)
pdns/signingpipe.cc

index 4eec80757d25c8edcd6e07bf40048786cccd3930..8f9817e694c846e34ffe1043091d65fdc1257db7 100644 (file)
@@ -200,7 +200,13 @@ void ChunkedSigningPipe::sendRRSetToWorker() // it sounds so socialist!
   if(wantWrite && !rwVect.second.empty()) {
     shuffle(rwVect.second.begin(), rwVect.second.end(), pdns::dns_random_engine()); // pick random available worker
     auto ptr = d_rrsetToSign.release();
-    writen2(*rwVect.second.begin(), &ptr, sizeof(ptr));
+    try {
+      writen2(*rwVect.second.begin(), &ptr, sizeof(ptr));
+    }
+    catch (...) {
+      delete ptr;
+      throw;
+    }
     d_rrsetToSign = make_unique<rrset_t>();
     d_outstandings[*rwVect.second.begin()]++;
     d_outstanding++;
@@ -250,11 +256,18 @@ void ChunkedSigningPipe::sendRRSetToWorker() // it sounds so socialist!
     rwVect = waitForRW(false, wantWrite, -1); // wait for something to happen
     shuffle(rwVect.second.begin(), rwVect.second.end(), pdns::dns_random_engine()); // pick random available worker
     auto ptr = d_rrsetToSign.release();
-    writen2(*rwVect.second.begin(), &ptr, sizeof(ptr));
+    try {
+      writen2(*rwVect.second.begin(), &ptr, sizeof(ptr));
+    }
+    catch (...) {
+      delete ptr;
+      throw;
+    }
     d_rrsetToSign = make_unique<rrset_t>();
     d_outstandings[*rwVect.second.begin()]++;
     d_outstanding++;
     d_queued++;
+    // coverity[leaked_storage]
   }
   
 }