Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: zftp



Since I haven't posted a network patch today, here's a fix for closing a
zftp connection.  I only noticed this on Linux; Solaris was obviously
more forgiving about freed memory.

Index: Src/Modules/zftp.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/zftp.c,v
retrieving revision 1.26
diff -u -r1.26 zftp.c
--- Src/Modules/zftp.c	25 Apr 2002 14:06:47 -0000	1.26
+++ Src/Modules/zftp.c	15 May 2002 20:31:56 -0000
@@ -2678,14 +2678,15 @@
 	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) {

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk



Messages sorted by: Reverse Date, Date, Thread, Author