]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3490: part 1: SegFault opening FTP active data connections
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 8 Feb 2012 22:55:23 +0000 (11:55 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 8 Feb 2012 22:55:23 +0000 (11:55 +1300)
src/ftp.cc

index a34a726fad3e84f3bf516e033533232c9b053da6..8dd4d6c114b14bd3f73c61a6ad1f892d7cde5871 100644 (file)
@@ -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