diff svr-session.c @ 1040:2b4fd440399d

Free memory before exiting. Based on patch from Thorsten Horstmann. Client side is not complete.
author Matt Johnston <matt@ucc.asn.au>
date Tue, 24 Feb 2015 22:01:33 +0800
parents 0bb16232e7c4
children 3fb883a6aa81
line wrap: on
line diff
--- a/svr-session.c	Tue Feb 24 20:53:32 2015 +0800
+++ b/svr-session.c	Tue Feb 24 22:01:33 2015 +0800
@@ -78,10 +78,13 @@
 };
 
 static void
-svr_session_cleanup(void)
-{
+svr_session_cleanup(void) {
 	/* free potential public key options */
 	svr_pubkey_options_cleanup();
+
+	m_free(svr_ses.addrstring);
+	m_free(svr_ses.childpids);
+	m_free(svr_ses.remotehost);
 }
 
 static void
@@ -150,6 +153,7 @@
 void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
 
 	char fmtbuf[300];
+	int i;
 
 	if (!sessinitdone) {
 		/* before session init */
@@ -183,6 +187,15 @@
 		session_cleanup();
 	}
 
+	if (svr_opts.hostkey) {
+		sign_key_free(svr_opts.hostkey);
+		svr_opts.hostkey = NULL;
+	}
+	for (i = 0; i < DROPBEAR_MAX_PORTS; i++) {
+		m_free(svr_opts.addresses[i]);
+		m_free(svr_opts.ports[i]);
+	}
+
 	exit(exitcode);
 
 }