From 6edb0f66d53b34097146f2ec00f50d2a847b04c3 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 26 Jun 2013 21:50:27 +0100 Subject: [PATCH] Fix crash when telnet or other protocols close. http://code.google.com/p/flightgear-bugs/issues/detail?id=1144 --- simgear/io/sg_netChannel.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/simgear/io/sg_netChannel.cxx b/simgear/io/sg_netChannel.cxx index be8299f7..e62e120a 100644 --- a/simgear/io/sg_netChannel.cxx +++ b/simgear/io/sg_netChannel.cxx @@ -273,7 +273,6 @@ NetChannelPoller::poll(unsigned int timeout) int nreads = 0 ; int nwrites = 0 ; int nopen = 0 ; - NetChannel* ch; ChannelList::iterator it = channels.begin(); while( it != channels.end() ) @@ -281,6 +280,9 @@ NetChannelPoller::poll(unsigned int timeout) NetChannel* ch = *it; if ( ch -> should_delete ) { + // avoid the channel trying to remove itself from us, or we get + // bug http://code.google.com/p/flightgear-bugs/issues/detail?id=1144 + ch->poller = NULL; delete ch; it = channels.erase(it); continue; @@ -320,14 +322,14 @@ NetChannelPoller::poll(unsigned int timeout) for ( int i=0; reads[i]; i++ ) { - ch = (NetChannel*)reads[i]; + NetChannel* ch = (NetChannel*)reads[i]; if ( ! ch -> closed ) ch -> handleReadEvent(); } for ( int i=0; writes[i]; i++ ) { - ch = (NetChannel*)writes[i]; + NetChannel* ch = (NetChannel*)writes[i]; if ( ! ch -> closed ) ch -> handleWriteEvent(); } -- 2.39.5