From 95f421024a3b3c94a71c5328e23bf5456e7f14ba Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 29 Oct 2014 13:57:37 -0700 Subject: Code cleanup, and fix some unsafe pointer handling in Network. --- node/Network.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'node/Network.cpp') diff --git a/node/Network.cpp b/node/Network.cpp index e11d7d1a..2b9d59e1 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -535,15 +535,11 @@ void Network::threadMain() void Network::_CBhandleTapData(void *arg,const MAC &from,const MAC &to,unsigned int etherType,const Buffer<4096> &data) { - if ((!((Network *)arg)->_enabled)||(((Network *)arg)->status() != NETWORK_OK)) + SharedPtr network((Network *)arg,true); + if ((!network)||(!network->_enabled)||(network->status() != NETWORK_OK)) return; - - const RuntimeEnvironment *RR = ((Network *)arg)->RR; - if (RR->shutdownInProgress) - return; - try { - RR->sw->onLocalEthernet(SharedPtr((Network *)arg),from,to,etherType,data); + network->RR->sw->onLocalEthernet(network,from,to,etherType,data); } catch (std::exception &exc) { TRACE("unexpected exception handling local packet: %s",exc.what()); } catch ( ... ) { -- cgit v1.2.3