diff options
author | Adam Ierymenko <adam.ierymenko@zerotier.com> | 2014-03-06 15:11:08 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@zerotier.com> | 2014-03-06 15:11:08 -0800 |
commit | d0b506c12bd97a963ff11021cf8197b044372855 (patch) | |
tree | 75babd8b222216c72fd42712ee2f8199d51e3358 | |
parent | 742261c7fc8181e5c1a7567d9fdf51518d90c8bf (diff) | |
download | infinitytier-d0b506c12bd97a963ff11021cf8197b044372855.tar.gz infinitytier-d0b506c12bd97a963ff11021cf8197b044372855.zip |
Fix crash on uninitialized taps.
-rw-r--r-- | node/Network.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
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; } |