From: Remi Gacogne Date: Fri, 4 May 2018 09:02:31 +0000 (+0100) Subject: rec: Set pointers to nullptr after delete in the broadcast functions X-Git-Tag: dnsdist-1.3.1~89^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49467864788595048c0e2607a8992602ce518950;p=thirdparty%2Fpdns.git rec: Set pointers to nullptr after delete in the broadcast functions --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index d0f68a5ca0..ccb4e75b55 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -2462,13 +2462,14 @@ void broadcastFunction(const pipefunc_t& func) unixDie("write to thread pipe returned wrong size or error"); } - string* resp; + string* resp = nullptr; if(read(tps.readFromThread, &resp, sizeof(resp)) != sizeof(resp)) unixDie("read from thread pipe returned wrong size or error"); if(resp) { // cerr <<"got response: " << *resp << endl; delete resp; + resp = nullptr; } } } @@ -2585,7 +2586,7 @@ template T broadcastAccFunction(const boost::function& func) unixDie("write to thread pipe returned wrong size or error"); } - T* resp; + T* resp = nullptr; if(read(tps.readFromThread, &resp, sizeof(resp)) != sizeof(resp)) unixDie("read from thread pipe returned wrong size or error"); @@ -2593,6 +2594,7 @@ template T broadcastAccFunction(const boost::function& func) //~ cerr <<"got response: " << *resp << endl; ret += *resp; delete resp; + resp = nullptr; } } return ret;