diff options
author | Joseph Henry <josephjah@gmail.com> | 2016-01-17 14:32:34 -0800 |
---|---|---|
committer | Joseph Henry <josephjah@gmail.com> | 2016-01-17 14:32:34 -0800 |
commit | a73638b214a49828c982d8780c1b7b6bee610722 (patch) | |
tree | 35206726e74182f0819c16e5a65840d420bfcd2e /netcon | |
parent | 58ebfdffcb91b1050170c64ffd01e8b9ac2ae93f (diff) | |
download | infinitytier-a73638b214a49828c982d8780c1b7b6bee610722.tar.gz infinitytier-a73638b214a49828c982d8780c1b7b6bee610722.zip |
Fixed memory leak
Diffstat (limited to 'netcon')
-rw-r--r-- | netcon/NetconEthernetTap.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/netcon/NetconEthernetTap.cpp b/netcon/NetconEthernetTap.cpp index bcd678db..c0691dbd 100644 --- a/netcon/NetconEthernetTap.cpp +++ b/netcon/NetconEthernetTap.cpp @@ -420,6 +420,7 @@ void NetconEthernetTap::removeConnection(TcpConnection *conn) for(size_t i=0;i<_TcpConnections.size();++i) { if(_TcpConnections[i] == conn){ _TcpConnections.erase(_TcpConnections.begin() + i); + delete conn; return; } } @@ -435,18 +436,17 @@ void NetconEthernetTap::closeConnection(PhySocket *sock) TcpConnection *conn = getConnection(sock); if(!conn) return; - else - removeConnection(conn); - if(!conn->pcb) - return; - if(conn->pcb->state == SYN_SENT || conn->pcb->state == CLOSE_WAIT) { - dwr(MSG_DEBUG," closeConnection(): invalid PCB state for this operation. ignoring.\n"); - return; - } - dwr(MSG_DEBUG," closeConnection(): PCB->state = %d\n", conn->pcb->state); - if(lwipstack->_tcp_close(conn->pcb) != ERR_OK) { - dwr(MSG_ERROR," closeConnection(): error while calling tcp_close()\n"); + if(conn->pcb) { + if(conn->pcb->state == SYN_SENT || conn->pcb->state == CLOSE_WAIT) { + dwr(MSG_DEBUG," closeConnection(): invalid PCB state for this operation. ignoring.\n"); + return; + } + dwr(MSG_DEBUG," closeConnection(): PCB->state = %d\n", conn->pcb->state); + if(lwipstack->_tcp_close(conn->pcb) != ERR_OK) { + dwr(MSG_ERROR," closeConnection(): error while calling tcp_close()\n"); + } } + removeConnection(conn); if(!sock) return; close(_phy.getDescriptor(sock)); |