diff --git a/node/Topology.cpp b/node/Topology.cpp index a3faaf238..c7de22a8b 100644 --- a/node/Topology.cpp +++ b/node/Topology.cpp @@ -96,27 +96,34 @@ Topology::Topology(const RuntimeEnvironment *renv) : Topology::~Topology() { - Buffer pbuf; - std::string all; + Buffer *pbuf = 0; + try { + pbuf = new Buffer(); + std::string all; - Address *a = (Address *)0; - SharedPtr *p = (SharedPtr *)0; - Hashtable< Address,SharedPtr >::Iterator i(_peers); - while (i.next(a,p)) { - if (std::find(_rootAddresses.begin(),_rootAddresses.end(),*a) == _rootAddresses.end()) { - pbuf.clear(); - try { - (*p)->serialize(pbuf); + Address *a = (Address *)0; + SharedPtr *p = (SharedPtr *)0; + Hashtable< Address,SharedPtr >::Iterator i(_peers); + while (i.next(a,p)) { + if (std::find(_rootAddresses.begin(),_rootAddresses.end(),*a) == _rootAddresses.end()) { + pbuf->clear(); try { - all.append((const char *)pbuf.data(),pbuf.size()); - } catch ( ... ) { - return; // out of memory? just skip - } - } catch ( ... ) {} // peer too big? shouldn't happen, but it so skip + (*p)->serialize(*pbuf); + try { + all.append((const char *)pbuf->data(),pbuf->size()); + } catch ( ... ) { + return; // out of memory? just skip + } + } catch ( ... ) {} // peer too big? shouldn't happen, but it so skip + } } - } - RR->node->dataStorePut("peers.save",all,true); + RR->node->dataStorePut("peers.save",all,true); + + delete pbuf; + } catch ( ... ) { + delete pbuf; + } } SharedPtr Topology::addPeer(const SharedPtr &peer) diff --git a/one.cpp b/one.cpp index 11bcc11e7..685034dfe 100644 --- a/one.cpp +++ b/one.cpp @@ -966,7 +966,7 @@ int main(int argc,char **argv) #ifdef ZT_WIN_RUN_IN_CONSOLE bool winRunFromCommandLine = true; #else - bool winRunFromCommandLine = true; + bool winRunFromCommandLine = false; #endif #endif // __WINDOWS__