Browse Source

Fix segfault with > 32 servers.

Signed-off-by: Bradley Smith <brad@brad-smith.co.uk>
Bradley Smith 10 years ago
parent
commit
2fe3b57828
2 changed files with 12 additions and 3 deletions
  1. 10 1
      src/mssh-window.c
  2. 2 2
      src/mssh-window.h

+ 10 - 1
src/mssh-window.c

@@ -29,6 +29,10 @@ static void mssh_window_sendhost(GtkWidget *widget, gpointer data)
 
 static void mssh_window_destroy(GtkWidget *widget, gpointer data)
 {
+	MSSHWindow *window = MSSH_WINDOW(data);
+
+	free(window->terms);
+	free(window->items);
 	gtk_main_quit();
 }
 
@@ -107,7 +111,7 @@ static void mssh_window_init(MSSHWindow* window)
 	g_signal_connect(G_OBJECT(window->file_sendhost), "activate",
 		G_CALLBACK(mssh_window_sendhost), window);
 	g_signal_connect(G_OBJECT(window->file_quit), "activate",
-		G_CALLBACK(mssh_window_destroy), NULL);
+		G_CALLBACK(mssh_window_destroy), window);
 	gtk_widget_add_accelerator(window->file_quit, "activate", accel_group,
 		GDK_W, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
 	gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
@@ -142,6 +146,11 @@ void mssh_window_new_session(MSSHWindow* window, char **env,
 	window->num_servers = num_servers;
 	window->servers = servers;
 
+	window->items = malloc(sizeof(GtkWidget) * num_servers);
+	window->terms = malloc(sizeof(GtkWidget) * num_servers);
+	memset(window->items, 0, sizeof(GtkWidget) * num_servers);
+	memset(window->terms, 0, sizeof(GtkWidget) * num_servers);
+
 	args[0] = strdup("ssh");
 
 	window->table = gtk_table_new(rows, 2, TRUE);

+ 2 - 2
src/mssh-window.h

@@ -32,8 +32,8 @@ typedef struct
 	char **env;
 	char **servers;
 	int num_servers;
-	GtkWidget *items[32];
-	GtkWidget *terms[32];
+	GtkWidget **items;
+	GtkWidget **terms;
 } MSSHWindow;
 
 typedef struct