< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] Memory leak patch for AresDns.cxx


The attached patch fixes a few memory leaks in AresDns.cxx when making calls 
to ares_query().  In each case a new AresDns::Payload object was created but 
never deleted.  The patch deletes these objects in the appropriate callbacks.

Regards,
~Scott
Index: resiprocate/AresDns.cxx
===================================================================
--- resiprocate/AresDns.cxx	(revision 3812)
+++ resiprocate/AresDns.cxx	(working copy)
@@ -66,6 +66,7 @@
 {
    Payload* p = reinterpret_cast<Payload*>(arg);
    ExternalDnsHandler *thisp = reinterpret_cast<ExternalDnsHandler*>(p->first);
+   delete p;
    return thisp;
 }
 
@@ -74,6 +75,7 @@
 {
    Payload* p = reinterpret_cast<Payload*>(arg);
    void* userArg = reinterpret_cast<void*>(p->second);
+   delete p;
    
    if (status != ARES_SUCCESS)
    {
@@ -91,6 +93,7 @@
    Payload* p = reinterpret_cast<Payload*>(arg);
    ExternalDnsHandler *thisp = reinterpret_cast<ExternalDnsHandler*>(p->first);
    void* userArg = reinterpret_cast<void*>(p->second);
+   delete p;
 
    if (status != ARES_SUCCESS)
    {