From 6d424339e781a51a704778e42012d0f3af0a9f96 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Fri, 24 Feb 2012 21:18:44 -0700 Subject: [PATCH] Bug 3490: part 1: SegFault opening FTP active data connections --- src/ftp.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 -- 2.47.2