NetworkManager r3940 - in trunk: . system-settings/plugins/ifcfg-fedora



Author: dcbw
Date: Tue Aug 12 17:47:21 2008
New Revision: 3940
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3940&view=rev

Log:
2008-08-12  Dan Williams  <dcbw redhat com>

	* system-settings/plugins/ifcfg-fedora/shvar.c
	  system-settings/plugins/ifcfg-fedora/shvar.c
		- Fix double-free caused by svSetValue() followed by svCloseFile()



Modified:
   trunk/ChangeLog
   trunk/system-settings/plugins/ifcfg-fedora/shvar.c
   trunk/system-settings/plugins/ifcfg-fedora/shvar.h

Modified: trunk/system-settings/plugins/ifcfg-fedora/shvar.c
==============================================================================
--- trunk/system-settings/plugins/ifcfg-fedora/shvar.c	(original)
+++ trunk/system-settings/plugins/ifcfg-fedora/shvar.c	Tue Aug 12 17:47:21 2008
@@ -121,9 +121,13 @@
     len = strlen(s);
     if ((s[0] == '"' || s[0] == '\'') && s[0] == s[len-1]) {
 	i = len - 2;
-	memmove(s, s+1, i);
-	s[i+1] = '\0';
-	len = i;
+	if (i == 0)
+	  s[0] = '\0';
+	else {
+	  memmove(s, s+1, i);
+	  s[i+1] = '\0';
+	  len = i;
+	}
     }
     for (i = 0; i < len; i++) {
 	if (s[i] == '\\') {
@@ -291,7 +295,6 @@
 	    /* change/append line to get key= */
 	    if (s->current) s->current->data = keyValue;
 	    else s->lineList = g_list_append(s->lineList, keyValue);
-	    s->freeList = g_list_append(s->freeList, keyValue);
 	    s->modified = 1;
 	} else if (val1) {
 	    /* delete line */
@@ -307,7 +310,6 @@
 	if (val2 && !strcmp(val2, newval)) goto end;
 	/* append line */
 	s->lineList = g_list_append(s->lineList, keyValue);
-	s->freeList = g_list_append(s->freeList, keyValue);
 	s->modified = 1;
 	goto end;
     }
@@ -326,7 +328,6 @@
 	/* change line */
 	if (s->current) s->current->data = keyValue;
 	else s->lineList = g_list_append(s->lineList, keyValue);
-	s->freeList = g_list_append(s->freeList, keyValue);
 	s->modified = 1;
     }
 
@@ -387,11 +388,7 @@
     if (s->fd != -1) close(s->fd);
 
     g_free(s->arena);
-    for (s->current = s->freeList; s->current; s->current = s->current->next) {
-        g_free(s->current->data);
-    }
     g_free(s->fileName);
-    g_list_free(s->freeList);
     g_list_foreach (s->lineList, (GFunc) g_free, NULL);
     g_list_free(s->lineList); /* implicitly frees s->current */
     g_free(s);

Modified: trunk/system-settings/plugins/ifcfg-fedora/shvar.h
==============================================================================
--- trunk/system-settings/plugins/ifcfg-fedora/shvar.h	(original)
+++ trunk/system-settings/plugins/ifcfg-fedora/shvar.h	Tue Aug 12 17:47:21 2008
@@ -42,7 +42,6 @@
 	int		fd;		/* read-only */
 	char		*arena;		/* ignore */
 	GList		*lineList;	/* read-only */
-	GList		*freeList;	/* ignore */
 	GList		*current;	/* set implicitly or explicitly,
 					   points to element of lineList */
 	shvarFile	*parent;	/* set explicitly */



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