Skip to content

Commit 669a475

Browse files
author
Patrick Kwong
committed
set m_client = NULL before remove_socket which will free itself
1 parent a725bb6 commit 669a475

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/sio_socket.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ namespace sio
316316
void socket::impl::on_close()
317317
{
318318
NULL_GUARD(m_client);
319+
sio::client_impl *client = m_client;
320+
m_client = NULL;
321+
319322
if(m_connection_timer)
320323
{
321324
m_connection_timer->cancel();
@@ -325,9 +328,8 @@ namespace sio
325328
while (!m_packet_queue.empty()) {
326329
m_packet_queue.pop();
327330
}
328-
m_client->on_socket_closed(m_nsp);
329-
m_client->remove_socket(m_nsp);
330-
m_client = NULL;
331+
client->on_socket_closed(m_nsp);
332+
client->remove_socket(m_nsp);
331333
}
332334

333335
void socket::impl::on_open()

0 commit comments

Comments
 (0)