From: Amos Jeffries Date: Wed, 8 Feb 2012 22:55:23 +0000 (+1300) Subject: Bug 3490: part 1: SegFault opening FTP active data connections X-Git-Tag: BumpSslServerFirst.take05~12^2~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b2e3fa62ec6dcc61df5deeb53a9dcca652f4c718;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 a34a726fad..8dd4d6c114 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -2768,11 +2768,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); /* @@ -3908,10 +3910,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