]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Set pointers to nullptr after delete in the broadcast functions
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 4 May 2018 09:02:31 +0000 (10:02 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 16 May 2018 15:22:02 +0000 (17:22 +0200)
pdns/pdns_recursor.cc

index d0f68a5ca0a3a9295a36ea51f8b17f279ade4f3b..ccb4e75b556c5bc0b482b4977c53f860f8645a4d 100644 (file)
@@ -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<class T> T broadcastAccFunction(const boost::function<T*()>& 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<class T> T broadcastAccFunction(const boost::function<T*()>& func)
       //~ cerr <<"got response: " << *resp << endl;
       ret += *resp;
       delete resp;
+      resp = nullptr;
     }
   }
   return ret;