aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-08-04 23:43:42 +0000
committerGuy Harris <guy@alum.mit.edu>1999-08-04 23:43:42 +0000
commit41a8a32b7baa909fc43ea2faccd201cd00b6b518 (patch)
treef58a37dde6d9ab77199dbd325bd733b5c4068163
parent5161130b4b80b795c1cacbea0193d9cdbc211970 (diff)
Fix a couple of memory leaks.
svn path=/trunk/; revision=438
-rw-r--r--file.c3
-rw-r--r--proto.c22
2 files changed, 15 insertions, 10 deletions
diff --git a/file.c b/file.c
index 6dc9d7d69b..0def5e03d4 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.53 1999/08/02 02:04:25 guy Exp $
+ * $Id: file.c,v 1.54 1999/08/04 23:43:42 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -431,6 +431,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, const u_char *buf
protocol_tree = proto_tree_create_root();
dissect_packet(buf, fdata, protocol_tree);
fdata->passed_dfilter = dfilter_apply(cf->dfcode, protocol_tree, cf->pd);
+ proto_tree_free(protocol_tree);
}
else {
dissect_packet(buf, fdata, NULL);
diff --git a/proto.c b/proto.c
index 81e2d45478..44cbd6f0d8 100644
--- a/proto.c
+++ b/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.10 1999/08/03 14:59:16 gram Exp $
+ * $Id: proto.c,v 1.11 1999/08/04 23:43:42 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -69,7 +69,7 @@
#define WITH_SNMP_CMU 1
#endif
-static void
+static gboolean
proto_tree_free_node(GNode *node, gpointer data);
static struct header_field_info*
@@ -249,18 +249,22 @@ void
proto_tree_free(proto_tree *tree)
{
g_node_traverse((GNode*)tree, G_IN_ORDER, G_TRAVERSE_ALL, -1,
- (GNodeTraverseFunc)proto_tree_free_node, NULL);
+ proto_tree_free_node, NULL);
}
-static void
+static gboolean
proto_tree_free_node(GNode *node, gpointer data)
{
field_info *fi = (field_info*) (node->data);
- if (fi->representation)
- g_mem_chunk_free(gmc_item_labels, fi->representation);
- if (fi->hfinfo->type == FT_STRING)
- g_free(fi->value.string);
- g_mem_chunk_free(gmc_field_info, fi);
+
+ if (fi != NULL) {
+ if (fi->representation)
+ g_mem_chunk_free(gmc_item_labels, fi->representation);
+ if (fi->hfinfo->type == FT_STRING)
+ g_free(fi->value.string);
+ g_mem_chunk_free(gmc_field_info, fi);
+ }
+ return FALSE; /* FALSE = do not end traversal of GNode tree */
}
/* Finds a record in the hf_info_records array. */