[PATCH] Cleanup of channels.

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 




Attached patch frees a few more memory blocks that would otherwise leak at the end of the program (rather inconsequential).


Markus
diff --git a/channels.c b/channels.c
index 657381b..0a32cb2 100644
--- a/channels.c
+++ b/channels.c
@@ -639,10 +639,41 @@ void
 channel_free_all(struct ssh *ssh)
 {
 	u_int i;
+	struct ssh_channels *sc = ssh->chanctxt;
 
-	for (i = 0; i < ssh->chanctxt->channels_alloc; i++)
-		if (ssh->chanctxt->channels[i] != NULL)
-			channel_free(ssh, ssh->chanctxt->channels[i]);
+
+	for (i = 0; i < sc->channels_alloc; i++)
+		if (sc->channels[i] != NULL)
+			channel_free(ssh, sc->channels[i]);
+
+	free(sc->channels);
+	sc->channels= NULL;
+
+	sc->channels_alloc = 0;
+	sc->channel_max_fd = 0;
+
+
+	if (sc->x11_saved_display) {
+		free(sc->x11_saved_display);
+		sc->x11_saved_display= NULL;
+	}
+
+	if (sc->x11_saved_proto) {
+		free(sc->x11_saved_proto);
+		sc->x11_saved_proto= NULL;
+	}
+
+	if (sc->x11_saved_data) {
+		free(sc->x11_saved_data);
+		sc->x11_saved_data= NULL;
+		sc->x11_saved_data_len = 0;
+	}
+
+	if (sc->x11_fake_data) {
+		free(sc->x11_fake_data);
+		sc->x11_fake_data= NULL;
+		sc->x11_fake_data_len = 0;
+	}
 }
 
 /*
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux