From d0b506c12bd97a963ff11021cf8197b044372855 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 6 Mar 2014 15:11:08 -0800 Subject: Fix crash on uninitialized taps. --- node/Network.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'node') diff --git a/node/Network.cpp b/node/Network.cpp index 12fc5849..a119ac9c 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -60,8 +60,11 @@ Network::~Network() { Thread::join(_setupThread); - std::string devPersistentId(_tap->persistentId()); - delete _tap; + std::string devPersistentId; + if (_tap) { + devPersistentId = _tap->persistentId(); + delete _tap; + } if (_destroyOnDelete) { Utils::rm(std::string(_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d" + ZT_PATH_SEPARATOR_S + idString() + ".conf")); @@ -296,9 +299,13 @@ void Network::threadMain() _nc->putLocalConfig(lcentry,dn); #endif } catch (std::exception &exc) { + delete _tap; + _tap = (EthernetTap *)0; LOG("network %.16llx failed to initialize: %s",_id,exc.what()); _netconfFailure = NETCONF_FAILURE_INIT_FAILED; } catch ( ... ) { + delete _tap; + _tap = (EthernetTap *)0; LOG("network %.16llx failed to initialize: unknown error",_id); _netconfFailure = NETCONF_FAILURE_INIT_FAILED; } -- cgit v1.2.3