Ethereal-dev: [Ethereal-dev] [patch] memory leak in tvbuff after a call to tvb_set_child_real_

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

From: didier <dgautheron@xxxxxxxx>
Date: Wed, 15 Feb 2006 00:10:58 +0000
Hi
I'm not sure it's the right way to do it but it seems to work.

Didier
Index: epan/tvbuff.c
===================================================================
--- epan/tvbuff.c	(revision 17304)
+++ epan/tvbuff.c	(working copy)
@@ -99,9 +99,6 @@
 
 	switch(type) {
 		case TVBUFF_REAL_DATA:
-			/* Nothing */
-			break;
-
 		case TVBUFF_SUBSET:
 			backing = &tvb->tvbuffs.subset;
 			backing->tvb	= NULL;
@@ -149,6 +146,9 @@
 				 */
 				tvb->free_cb((gpointer)tvb->real_data);
 			}
+			if (tvb->tvbuffs.subset.tvb) {
+				tvb_decrement_usage_count(tvb->tvbuffs.subset.tvb, 1);
+			}
 			break;
 
 		case TVBUFF_SUBSET:
@@ -249,6 +249,7 @@
 	DISSECTOR_ASSERT(parent->initialized);
 	DISSECTOR_ASSERT(child->initialized);
 	DISSECTOR_ASSERT(child->type == TVBUFF_REAL_DATA);
+	child->tvbuffs.subset.tvb = parent;
 	add_to_used_in_list(parent, child);
 }