From 757f8a7dc706b83e969309d44bc04dc38785d157 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Fri, 16 Aug 2013 11:41:25 +0200 Subject: Fixed segfault at POP3 connection error. --- src/net/pop3/POP3Connection.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/net/pop3/POP3Connection.cpp b/src/net/pop3/POP3Connection.cpp index 33349749..948242d7 100644 --- a/src/net/pop3/POP3Connection.cpp +++ b/src/net/pop3/POP3Connection.cpp @@ -188,18 +188,25 @@ void POP3Connection::disconnect() void POP3Connection::internalDisconnect() { - try - { - POP3Command::QUIT()->send(thisRef().dynamicCast ()); - POP3Response::readResponse(thisRef().dynamicCast ()); - } - catch (exception&) + if (m_socket) { - // Not important - } + if (m_socket->isConnected()) + { + try + { + POP3Command::QUIT()->send(thisRef().dynamicCast ()); + POP3Response::readResponse(thisRef().dynamicCast ()); + } + catch (exception&) + { + // Not important + } - m_socket->disconnect(); - m_socket = NULL; + m_socket->disconnect(); + } + + m_socket = NULL; + } m_timeoutHandler = NULL; -- cgit