about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-05-15 20:38:17 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-05-15 20:38:17 +0000
commitbbefa484f47ba659afa78b6a3c8621a17ed29e03 (patch)
tree57af6127bcca84a1b2970c01f335be0ba0457d25 /Src
parentcd50acd08da88d54c808af9168e61328f5d2160c (diff)
downloadzsh-bbefa484f47ba659afa78b6a3c8621a17ed29e03.tar.gz
zsh-bbefa484f47ba659afa78b6a3c8621a17ed29e03.tar.xz
zsh-bbefa484f47ba659afa78b6a3c8621a17ed29e03.zip
17166: Src/Modules/zftp.c: check fileno of zftp control
connection before closing, not after
Diffstat (limited to 'Src')
-rw-r--r--Src/Modules/zftp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c
index 80e09045c..de762e883 100644
--- a/Src/Modules/zftp.c
+++ b/Src/Modules/zftp.c
@@ -2678,14 +2678,15 @@ zfclose(int leaveparams)
 	zfsendcmd("QUIT\r\n");
     }
     if (zfsess->cin) {
-	fclose(zfsess->cin);
 	/*
 	 * We fdopen'd the TCP control fd; since we can't fdclose it,
 	 * we need to perform a full fclose, which invalidates the
-	 * TCP fd.
+	 * TCP fd.  We need to do this before closing the FILE, since
+	 * it's not usable afterwards.
 	 */
 	if (fileno(zfsess->cin) == zfsess->control->fd)
 	    zfsess->control->fd = -1;
+	fclose(zfsess->cin);
 	zfsess->cin = NULL;
     }
     if (zfsess->control) {