Required for plaintext-upgrade-attack.patch to run successfully. From 91d19cb8530cb8df6ec0ee0580abcd98f1957395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Mon, 5 Sep 2016 12:47:28 +0200 Subject: [PATCH] tests: fix more memleaks There's some progress, but still plenty of stuff to do: -SUMMARY: AddressSanitizer: 77490 byte(s) leaked in 1010 allocation(s). +SUMMARY: AddressSanitizer: 7720 byte(s) leaked in 95 allocation(s). Change-Id: I133fda902a9bd3f9fe697d7ffe8c57a159c887d8 --- tests/Imap/test_Imap_Tasks_OpenConnection.cpp | 16 ++++++++-------- tests/Imap/test_Imap_Tasks_OpenConnection.h | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/Imap/test_Imap_Tasks_OpenConnection.cpp b/tests/Imap/test_Imap_Tasks_OpenConnection.cpp index b3a95636..c40297ab 100644 --- a/tests/Imap/test_Imap_Tasks_OpenConnection.cpp +++ b/tests/Imap/test_Imap_Tasks_OpenConnection.cpp @@ -35,12 +35,11 @@ void ImapModelOpenConnectionTest::initTestCase() { LibMailboxSync::initTestCase(); qRegisterMetaType(); - completedSpy = 0; - m_enableAutoLogin = true; } void ImapModelOpenConnectionTest::init() { + m_enableAutoLogin = true; reinit(TlsRequired::No); } @@ -56,13 +55,14 @@ void ImapModelOpenConnectionTest::reinit(const TlsRequired tlsRequired) connect(model, &Imap::Mailbox::Model::needsSslDecision, this, &ImapModelOpenConnectionTest::acceptSsl, Qt::QueuedConnection); LibMailboxSync::setModelNetworkPolicy(model, Imap::Mailbox::NETWORK_ONLINE); QCoreApplication::processEvents(); + delete task; task = new Imap::Mailbox::OpenConnectionTask(model); - completedSpy = new QSignalSpy(task, SIGNAL(completed(Imap::Mailbox::ImapTask*))); - failedSpy = new QSignalSpy(task, SIGNAL(failed(QString))); - authSpy = new QSignalSpy(model, SIGNAL(authRequested())); - connErrorSpy = new QSignalSpy(model, SIGNAL(imapError(QString))); - startTlsUpgradeSpy = new QSignalSpy(model, SIGNAL(requireStartTlsInFuture())); - authErrorSpy = new QSignalSpy(model, SIGNAL(imapAuthErrorChanged(const QString&))); + completedSpy.reset(new QSignalSpy(task, SIGNAL(completed(Imap::Mailbox::ImapTask*)))); + failedSpy.reset(new QSignalSpy(task, SIGNAL(failed(QString)))); + authSpy.reset(new QSignalSpy(model, SIGNAL(authRequested()))); + connErrorSpy.reset(new QSignalSpy(model, SIGNAL(imapError(QString)))); + startTlsUpgradeSpy.reset(new QSignalSpy(model, SIGNAL(requireStartTlsInFuture()))); + authErrorSpy.reset(new QSignalSpy(model, SIGNAL(imapAuthErrorChanged(const QString&)))); t.reset(); } diff --git a/tests/Imap/test_Imap_Tasks_OpenConnection.h b/tests/Imap/test_Imap_Tasks_OpenConnection.h index 30f531a2..4df65c05 100644 --- a/tests/Imap/test_Imap_Tasks_OpenConnection.h +++ b/tests/Imap/test_Imap_Tasks_OpenConnection.h @@ -78,13 +78,13 @@ protected: void reinit(const TlsRequired tlsRequired = TlsRequired::No); private: - Imap::Mailbox::OpenConnectionTask* task; - QSignalSpy* completedSpy; - QSignalSpy* failedSpy; - QSignalSpy* authSpy; - QSignalSpy *connErrorSpy; - QSignalSpy *startTlsUpgradeSpy; - QSignalSpy *authErrorSpy; + QPointer task; + std::unique_ptr completedSpy; + std::unique_ptr failedSpy; + std::unique_ptr authSpy; + std::unique_ptr connErrorSpy; + std::unique_ptr startTlsUpgradeSpy; + std::unique_ptr authErrorSpy; bool m_enableAutoLogin; }; -- GitLab