fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.

This commit is contained in:
Mathieu Lacage committed 2007-05-03 13:11:50 +02:00
1 parent b23a6e2dac
commit 2b1f2aba00
6 files changed
+50 -3

No files matched your search

+25 -1
View File
@@ -40,7 +40,31 @@ UdpSocket::UdpSocket (Node *node)
}
UdpSocket::~UdpSocket ()
{
Destroy ();
if (m_node != 0)
{
m_node->Unref ();
m_node = 0;
}
if (m_endPoint != 0)
{
NS_ASSERT (m_udp != 0);
/**
* Note that this piece of code is a bit tricky:
* when DeAllocate is called, it will call into
* Ipv4EndPointDemux::Deallocate which triggers
* a delete of the associated endPoint which triggers
* in turn a call to the method ::Destroy below
* will will zero the m_endPoint field.
*/
NS_ASSERT (m_endPoint != 0);
m_udp->DeAllocate (m_endPoint);
NS_ASSERT (m_endPoint == 0);
}
if (m_udp != 0)
{
m_udp->Unref ();
m_udp = 0;
}
}
Node *