From d9f4d1e0171dd3129cf38e793f1475e60290d611 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Sat, 17 Oct 2020 16:51:03 -0700 Subject: [PATCH] dsr: Avoid possible segmentation fault in DsrRouting::DoDispose --- src/dsr/model/dsr-routing.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/dsr/model/dsr-routing.cc b/src/dsr/model/dsr-routing.cc index 802292c51..90b601f4e 100644 --- a/src/dsr/model/dsr-routing.cc +++ b/src/dsr/model/dsr-routing.cc @@ -557,12 +557,16 @@ DsrRouting::DoDispose (void) Ptr wifi = dev->GetObject (); if (wifi != 0) { - Ptr mac = wifi->GetMac ()->GetObject (); + Ptr mac = wifi->GetMac (); if (mac != 0) { - mac->TraceDisconnectWithoutContext ("TxErrHeader", + Ptr adhoc = mac->GetObject (); + if (adhoc) + { + adhoc->TraceDisconnectWithoutContext ("TxErrHeader", m_routeCache->GetTxErrorCallback ()); - m_routeCache->DelArpCache (m_ipv4->GetInterface (i)->GetArpCache ()); + m_routeCache->DelArpCache (m_ipv4->GetInterface (i)->GetArpCache ()); + } } } }