Re: [PATCH] Fix crasher + leak when specifying domain in connect server dialog



Am Mittwoch, den 14.09.2005, 01:21 +0200 schrieb Christian Neumair:
> The attached patch fixes bug 314730 [1] and a potential leak, since the
> user variable was not freed if the preceding if branch wasn't reached.
> Also, passing free'd pointers to g_strconcat is no good.
> 
> Sidenote: According to the GnomeVFS SMB-Method code, the domain/user
> will be figured out correctly even if user is "".

By 'if user is ""' I mean the value of the user entry.

The last patch potentially introduced a new crasher variant by always
freeing the previous user variable.
New patch attached.

> [1] http://bugzilla.gnome.org/show_bug.cgi?id=314730

-- 
Christian Neumair <chris gnome-de org>
Index: src/nautilus-connect-server-dialog.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-connect-server-dialog.c,v
retrieving revision 1.14
diff -u -p -r1.14 nautilus-connect-server-dialog.c
--- src/nautilus-connect-server-dialog.c	27 May 2005 08:46:04 -0000	1.14
+++ src/nautilus-connect-server-dialog.c	14 Sep 2005 09:09:59 -0000
@@ -212,14 +212,20 @@ connect_to_server (NautilusConnectServer
 			g_free (t);
 		}
 		if (dialog->details->domain_entry->parent != NULL) {
-	
 			free_domain = TRUE;
 
 			domain = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->domain_entry), 0, -1);
 			
 			if (strlen (domain) != 0) {
-				g_free (user);
-				user = g_strconcat (domain , ";" , user, NULL);
+				t = user;
+
+				user = g_strconcat (domain , ";" , t, NULL);
+
+				if (free_user) {
+					g_free (t);
+				}
+
+				free_user = TRUE;
 			}
 		}
 

Attachment: signature.asc
Description: This is a digitally signed message part



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