From c12f70b721a80dfbbfd4feb5c0f17ddef93d5a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20T=C5=91k=C3=A9s?= Date: Wed, 3 Jun 2015 23:27:54 +0300 Subject: [PATCH] Fix memory leak --- src/smtpclient.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/smtpclient.cpp b/src/smtpclient.cpp index aaa5909..e7876c8 100644 --- a/src/smtpclient.cpp +++ b/src/smtpclient.cpp @@ -29,7 +29,8 @@ SmtpClient::SmtpClient(const QString & host, int port, ConnectionType connection authMethod(AuthPlain), connectionTimeout(5000), responseTimeout(5000), - sendMessageTimeout(60000) + sendMessageTimeout(60000), + socket(NULL) { setConnectionType(connectionType); @@ -44,7 +45,10 @@ SmtpClient::SmtpClient(const QString & host, int port, ConnectionType connection this, SLOT(socketReadyRead())); } -SmtpClient::~SmtpClient() {} +SmtpClient::~SmtpClient() { + if (socket) + delete socket; +} /* [1] --- */ @@ -80,6 +84,9 @@ void SmtpClient::setConnectionType(ConnectionType ct) { this->connectionType = ct; + if (socket) + delete socket; + switch (connectionType) { case TcpConnection: