- (djm) Sync with OpenBSD:
   - markus@cvs.openbsd.org  2000/10/16 15:46:32
     [ssh.1]
     fixes from pekkas@netcore.fi
   - markus@cvs.openbsd.org  2000/10/17 14:28:11
     [atomicio.c]
     return number of characters processed; ok deraadt@
   - markus@cvs.openbsd.org  2000/10/18 12:04:02
     [atomicio.c]
     undo
   - markus@cvs.openbsd.org  2000/10/18 12:23:02
     [scp.c]
     replace atomicio(read,...) with read(); ok deraadt@
   - markus@cvs.openbsd.org  2000/10/18 12:42:00
     [session.c]
     restore old record login behaviour
   - deraadt@cvs.openbsd.org 2000/10/19 10:41:13
     [auth-skey.c]
     fmt string problem in unused code
   - provos@cvs.openbsd.org  2000/10/19 10:45:16
     [sshconnect2.c]
     don't reference freed memory. okay deraadt@
   - markus@cvs.openbsd.org  2000/10/21 11:04:23
     [canohost.c]
     typo, eramore@era-t.ericsson.se; ok niels@
   - markus@cvs.openbsd.org  2000/10/23 13:31:55
     [cipher.c]
     non-alignment dependent swap_bytes(); from
     simonb@wasabisystems.com/netbsd
   - markus@cvs.openbsd.org  2000/10/26 12:38:28
     [compat.c]
     add older vandyke products
   - markus@cvs.openbsd.org  2000/10/27 01:32:19
     [channels.c channels.h clientloop.c serverloop.c session.c]
     [ssh.c util.c]
     enable non-blocking IO on channels, and tty's (except for the
     client ttys).
   - markus@cvs.openbsd.org  2000/10/27 01:48:22
     channels.c channels.h clientloop.c
     deny agent/x11 forwarding unless requested; thanks to jwl@pobox.com
diff --git a/sshconnect2.c b/sshconnect2.c
index 1f3b5a2..6ba23d4 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -23,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: sshconnect2.c,v 1.26 2000/10/14 12:16:56 markus Exp $");
+RCSID("$OpenBSD: sshconnect2.c,v 1.27 2000/10/19 16:45:16 provos Exp $");
 
 #include <openssl/bn.h>
 #include <openssl/rsa.h>
@@ -979,7 +979,7 @@
 Authmethod *
 authmethod_get(char *authlist)
 {
-	char *name = NULL;
+	char *name = NULL, *authname_old;
 	Authmethod *method = NULL;
 	
 	/* Use a suitable default if we're passed a nil list.  */
@@ -1013,16 +1013,17 @@
 		method = NULL;
 	}
 
-	if (authname_current != NULL)
-		xfree(authname_current);
-
+	authname_old = authname_current;
 	if (method != NULL) {
 		debug("next auth method to try is %s", name);
 		authname_current = xstrdup(name);
-		return method;
 	} else {
 		debug("no more auth methods to try");
 		authname_current = NULL;
-		return NULL;
 	}
+
+	if (authname_old != NULL)
+		xfree(authname_old);
+
+	return (method);
 }