summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-09-29 15:22:52 (GMT)
committerTobias Markmann <tm@ayena.de>2016-09-29 15:22:52 (GMT)
commit9abfaaa771f91010dbe01a1b9b5b9e2801956718 (patch)
tree618a5f66ea97d3d8552f72aad6a8e1313c56ec6e /Swiften/FileTransfer
parent2bf44a1d641c3bc35546cb49d3766f2962f9a984 (diff)
downloadswift-9abfaaa771f91010dbe01a1b9b5b9e2801956718.zip
swift-9abfaaa771f91010dbe01a1b9b5b9e2801956718.tar.bz2
Fix uninitialised class members
Initialised previously uninitialised class members. Changed some raw pointers to std::unique_ptr for clearer and automatically initialised code. Test-Information: Builds on macOS 10.12 and unit tests pass in ASAN-enabled build. Change-Id: I7900fe6131119c228ca92c79c0ee8125137f2e48
Diffstat (limited to 'Swiften/FileTransfer')
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerManager.h2
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp24
2 files changed, 11 insertions, 15 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
index 6dbdd1b..3c06513 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
@@ -78,7 +78,7 @@ namespace Swift {
enum { Start, Initializing, Initialized } state;
SOCKS5BytestreamServer* server;
std::shared_ptr<ConnectionServer> connectionServer;
- int connectionServerPort;
+ int connectionServerPort = -1;
std::shared_ptr<NATTraversalGetPublicIPRequest> getPublicIPRequest;
std::shared_ptr<NATTraversalForwardPortRequest> forwardPortRequest;
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
index b241320..cb43d78 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
@@ -59,9 +59,9 @@ public:
crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
destination = "092a44d859d19c9eed676b551ee80025903351c2";
randomGen.seed(static_cast<unsigned int>(time(nullptr)));
- eventLoop = new DummyEventLoop();
- timerFactory = new DummyTimerFactory();
- connection = std::make_shared<MockeryConnection>(failingPorts, true, eventLoop);
+ eventLoop = std::unique_ptr<DummyEventLoop>(new DummyEventLoop());
+ timerFactory = std::unique_ptr<DummyTimerFactory>(new DummyTimerFactory());
+ connection = std::make_shared<MockeryConnection>(failingPorts, true, eventLoop.get());
//connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1));
//stream1 = std::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg")));
// connection->onDataRead.connect(boost::bind(&SOCKS5BytestreamClientSessionTest::handleDataRead, this, _1));
@@ -69,15 +69,13 @@ public:
void tearDown() {
//connection.reset();
- delete timerFactory;
- delete eventLoop;
}
void testForSessionReady() {
TestHelper helper;
connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1));
- SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory);
+ SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get());
clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1));
clientSession->start();
@@ -103,7 +101,7 @@ public:
TestHelper helper;
connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1));
- SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory);
+ SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get());
clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1));
clientSession->start();
@@ -123,7 +121,7 @@ public:
TestHelper helper;
connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1));
- SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory);
+ SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get());
clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1));
clientSession->start();
@@ -150,7 +148,7 @@ public:
TestHelper helper;
connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1));
- SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory);
+ SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get());
clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1));
clientSession->start();
@@ -178,7 +176,7 @@ public:
TestHelper helper;
connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1));
- SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory);
+ SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get());
clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1));
clientSession->start();
@@ -203,8 +201,6 @@ public:
CPPUNIT_ASSERT_EQUAL(createByteArray(vecptr(transferData), transferData.size()), helper.unprocessedInput);
}
-
-
private:
static ByteArray generateRandomByteArray(size_t len) {
boost::uniform_int<> dist(0, 255);
@@ -308,8 +304,8 @@ private:
private:
HostAddressPort destinationAddressPort;
std::string destination;
- DummyEventLoop* eventLoop;
- DummyTimerFactory* timerFactory;
+ std::unique_ptr<DummyEventLoop> eventLoop;
+ std::unique_ptr<DummyTimerFactory> timerFactory;
std::shared_ptr<MockeryConnection> connection;
const std::vector<HostAddressPort> failingPorts;
std::shared_ptr<CryptoProvider> crypto;