Ethereal-dev: [Ethereal-dev] Memleaks found with valgrind

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Mon, 29 Jul 2002 02:31:06 +0200
Hello List,

I just played with valgrind 1.0.0 a bit. It found a few minor memleaks.
I've fixed one of them. Attached are
- fix (I'm not really happy with it as it fixes the symptom, the real
  cause is a not so nice contstruct of allocating memory in one function
  and freeing it its calling function - or not)
- the command line I used to run valgrind
- a bzip2ed output file (stderr) of the valgrind run

  Ciao
    Jörg
--
Joerg Mayer                                          <jmayer@xxxxxxxxx>
I found out that "pro" means "instead of" (as in proconsul). Now I know
what proactive means.
Changelog: <jmayer@xxxxxxxxx>
 gtk/colors.c: Fix a memleak found by valgrind
   (Note that there are similar bugs in other functions that
   use the same construct with path!)

Index: ethereal/gtk/colors.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/colors.c,v
retrieving revision 1.20
diff -u -r1.20 colors.c
--- colors.c	2002/05/27 22:00:37	1.20
+++ colors.c	2002/07/29 00:13:04
@@ -154,7 +154,7 @@
 	guint16 fg_r, fg_g, fg_b, bg_r, bg_g, bg_b;
 	GdkColor fg_color, bg_color;
 	color_filter_t *colorf;
-	const gchar *path;
+	gchar *path;
 	FILE *f;
 	dfilter_t *temp_dfilter;
 
@@ -166,8 +166,11 @@
 			    "Could not open filter file\n\"%s\": %s.", path,
 			    strerror(errno));
 		}
+		g_free((gchar *)path);
 		return FALSE;
 	}
+	g_free((gchar *)path);
+	path = NULL;
 
 	do {
 		if (fgets(buf,sizeof buf, f) == NULL)

Attachment: runvalgrind.sh
Description: Bourne shell script

Attachment: stderr.bz2
Description: application/bunzip2