]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3490: part 1: SegFault opening FTP active data connections
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 25 Feb 2012 04:18:44 +0000 (21:18 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 25 Feb 2012 04:18:44 +0000 (21:18 -0700)
src/ftp.cc

index 9a624de64c3967a9edecdd8fa83f8df7d7681496..e92ebd631efa9ecc1034f868b793a899f6c22925 100644 (file)
@@ -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