From: Otto Moerbeek Date: Fri, 29 Apr 2022 09:42:48 +0000 (+0200) Subject: Don't leak on exception and another case that needs an annotation X-Git-Tag: auth-4.8.0-alpha0~116^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccbb25375229c378488de486b037876d6cf74c36;p=thirdparty%2Fpdns.git Don't leak on exception and another case that needs an annotation --- 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] } }