fix potential duplicate cleanup

This commit is contained in:
John
2021-11-12 19:14:03 +01:00
parent 42cf1590d2
commit 93542a4f90
2 changed files with 10 additions and 3 deletions
+4 -2
View File
@@ -183,8 +183,10 @@ void Connection::run() {
}
}
delete m_socket;
m_socket = nullptr;
if (m_socket) {
delete m_socket;
m_socket = nullptr;
}
logInfo(lf_network, "[%05d] connection closed", getID());
}
+6 -1
View File
@@ -231,7 +231,12 @@ class Connection : public Thread {
m_id = ++m_ids;
}
virtual ~Connection() { if (m_socket) delete m_socket; }
virtual ~Connection() {
if (m_socket) {
delete m_socket;
m_socket = nullptr;
}
}
/**
* endless loop for connection instance.
*/