Ethereal-dev: Re: [Ethereal-dev] Memory leak and packet_info structure.

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

From: Gilbert Ramirez <gram@xxxxxxxxxxxxxxx>
Date: Fri, 2 Nov 2001 15:34:49 -0600
On Fri, 02 Nov 2001 15:23:32 Sirop Erable wrote:
> Hi, from ethreal-0.8.19 in tvbuff.c there is a memory leek in the
> function "void tvb_free(tvbuff_t* tvb)". There should be at the end of
> the function (just before "g_chunk_free(tvb,
> tvbuff_mem_chunk);"):"if(tvb->ds_name & tvb->type != TVBUFF_SUBSET) 
> g_free(tvb->ds_name);".P.S. Is it possible to move the definition of
> tvbuff structure in tvbuff.h.

Thanks. I've made a slightly different fix:

Index: tvbuff.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/epan/tvbuff.c,v
retrieving revision 1.20
diff -u -r1.20 tvbuff.c
--- tvbuff.c	2001/10/29 21:56:48	1.20
+++ tvbuff.c	2001/11/02 21:37:46
@@ -143,6 +143,7 @@
 	tvb->real_data		= NULL;
 	tvb->raw_offset		= -1;
 	tvb->used_in		= NULL;
+    tvb->ds_name        = NULL;
 
 	switch(type) {
 		case TVBUFF_REAL_DATA:
@@ -235,6 +236,10 @@
 		if (tvb->used_in) {
 			g_slist_free(tvb->used_in);
 		}
+
+        if (tvb->ds_name) {
+            g_free(tvb->ds_name);
+        }
 
 		g_chunk_free(tvb, tvbuff_mem_chunk);
 	}

--gilbert