From ccbb25375229c378488de486b037876d6cf74c36 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 29 Apr 2022 11:42:48 +0200 Subject: [PATCH] Don't leak on exception and another case that needs an annotation --- pdns/signingpipe.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pdns/signingpipe.cc b/pdns/signingpipe.cc index 4eec80757d..8f9817e694 100644 --- a/pdns/signingpipe.cc +++ b/pdns/signingpipe.cc @@ -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(); 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(); d_outstandings[*rwVect.second.begin()]++; d_outstanding++; d_queued++; + // coverity[leaked_storage] } } -- 2.47.2