From: Amos Jeffries Date: Sat, 25 Feb 2012 04:18:44 +0000 (-0700) Subject: Bug 3490: part 1: SegFault opening FTP active data connections X-Git-Tag: SQUID_3_2_0_16~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d424339e781a51a704778e42012d0f3af0a9f96;p=thirdparty%2Fsquid.git Bug 3490: part 1: SegFault opening FTP active data connections --- diff --git a/src/ftp.cc b/src/ftp.cc index 9a624de64c..e92ebd631e 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -2767,11 +2767,13 @@ static void ftpOpenListenSocket(FtpStateData * ftpState, int fallback) { /// Close old data channels, if any. We may open a new one below. - if ((ftpState->data.conn->flags & COMM_REUSEADDR)) - // NP: in fact it points to the control channel. just clear it. - ftpState->data.clear(); - else - ftpState->data.close(); + if (ftpState->data.conn != NULL) { + if ((ftpState->data.conn->flags & COMM_REUSEADDR)) + // NP: in fact it points to the control channel. just clear it. + ftpState->data.clear(); + else + ftpState->data.close(); + } safe_free(ftpState->data.host); /* @@ -3907,10 +3909,9 @@ FtpChannel::close() // channels with active listeners will be closed when the listener handler dies. if (Comm::IsConnOpen(conn)) { comm_remove_close_handler(conn->fd, closer); - closer = NULL; conn->close(); // we do not expect to be called back } - conn = NULL; + clear(); } void