From 6f3edf951d29c40a79e9adac490186f18f709889 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 9 May 2012 17:49:36 -0700 Subject: [PATCH] Use shared pointers when building protocol messages to fix leaks. --- src/NetworkOPs.cpp | 4 ++-- src/Peer.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/NetworkOPs.cpp b/src/NetworkOPs.cpp index 37c6c0c32..3b7fb204c 100644 --- a/src/NetworkOPs.cpp +++ b/src/NetworkOPs.cpp @@ -88,7 +88,7 @@ Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans, // no cache the account balance information and always get it from the current ledger // theApp->getWallet().applyTransaction(trans); - newcoin::TMTransaction *tx=new newcoin::TMTransaction(); + boost::shared_ptr tx = boost::make_shared(); Serializer::pointer s; trans->getSTransaction()->getTransaction(*s, false); @@ -334,7 +334,7 @@ void NetworkOPs::switchLastClosedLedger(Ledger::pointer newLedger, bool normal) { // this ledger has already closed } - newcoin::TMStatusChange* s = new newcoin::TMStatusChange(); + boost::shared_ptr s = boost::make_shared(); s->set_newevent(normal ? newcoin::neACCEPTED_LEDGER : newcoin::neSWITCHED_LEDGER); s->set_ledgerseq(newLedger->getLedgerSeq()); diff --git a/src/Peer.cpp b/src/Peer.cpp index ffcc7116b..c06148382 100644 --- a/src/Peer.cpp +++ b/src/Peer.cpp @@ -716,17 +716,17 @@ void Peer::recvGetLedger(newcoin::TMGetLedger& packet) } // Figure out what information they want - newcoin::TMLedgerData* data = new newcoin::TMLedgerData; + boost::shared_ptr data = boost::make_shared(); uint256 lHash = ledger->getHash(); data->set_ledgerhash(lHash.begin(), lHash.size()); data->set_ledgerseq(ledger->getLedgerSeq()); data->set_type(packet.itype()); - if(packet.itype()==newcoin::liBASE) + if(packet.itype() == newcoin::liBASE) { Serializer nData(116); ledger->addRaw(nData); - newcoin::TMLedgerNode* node=data->add_nodes(); + newcoin::TMLedgerNode* node = data->add_nodes(); node->set_nodedata(nData.getDataPtr(), nData.getLength()); } else if ( (packet.itype()==newcoin::liTX_NODE) || (packet.itype()==newcoin::liAS_NODE) ) @@ -820,7 +820,7 @@ void Peer::sendHello() theApp->getWallet().getNodePrivate().signNodePrivate(mCookieHash, vchSig); - newcoin::TMHello* h = new newcoin::TMHello(); + boost::shared_ptr h = boost::make_shared(); h->set_version(theConfig.VERSION); h->set_ledgerindex(theApp->getOPs().getCurrentLedgerID());