Wireshark-dev: Re: [Wireshark-dev] Problems with epan\oids.c

From: "Peter Johansson" <peterjohansson73@xxxxxxxxx>
Date: Wed, 19 Mar 2008 08:01:27 +0100
2008/3/18, Stig Bjørlykke <stig.bjorlykke@xxxxxxxxx>:

I have no win32 experience to fix this, so if nobody can make this
work correctly I will propose the attached patch.  This will leak some
memory on win32, but it's better than not working...


--
Stig Bjørlykke
 
 
I modified your patch slightly to address Windows platforms where MS VC 6 is not used to compile the binaries. Compilations made with VC 6 will therefor not leak memory while the otherones will (no long term solution though).
 
/ Regards, Peter

 

Index: epan/oids.c
===================================================================
--- epan/oids.c	(revision 24688)
+++ epan/oids.c	(working copy)
@@ -291,12 +291,16 @@
 		for (t = types; t->type ; t++ ) {
 			char* name = smiRenderType(sT, SMI_RENDER_NAME);
 			if (name && t->name && g_str_equal(name, t->name )) {
+#if !defined WIN32 || (defined WIN32 && MSC_VER == 1200)
 				free (name);
+#endif
 				return t->type;
 			}
+#if !defined WIN32 || (defined WIN32 && MSC_VER == 1200)
 			if (name) {
 				free (name);
 			}
+#endif
 		}
 	} while(( sT  = smiGetParentType(sT) ));
 
@@ -384,9 +388,10 @@
 				oid1 = smiRenderOID(sN->oidlen, sN->oid, SMI_RENDER_QUALIFIED);
 				oid2 = smiRenderOID(elNode->oidlen, elNode->oid, SMI_RENDER_NAME);
 				k->name = g_strdup_printf("%s.%s", oid1, oid2);
+#if !defined WIN32 || (defined WIN32 && MSC_VER == 1200)
 				free (oid1);
 				free (oid2);
-
+#endif						  
 				k->hfid = -2;
 				k->ft_type = typedata ? typedata->ft_type : FT_BYTES;
 				k->display = typedata ? typedata->display : BASE_NONE;
@@ -575,7 +580,9 @@
 						       key,
 						       smiNode->oidlen,
 						       smiNode->oid);
+#if !defined WIN32 || (defined WIN32 && MSC_VER == 1200)
 			free (oid);
+#endif
 
 			D(4,("\t\tNode: kind=%d oid=%s name=%s ",
 				 oid_data->kind, oid_subid2string(smiNode->oid, smiNode->oidlen), oid_data->name ));
@@ -589,7 +596,11 @@
 					typedata->display,
 					NULL,
 					0,
+#if !defined WIN32 || (defined WIN32 && MSC_VER == 1200)
 					smiRenderOID(smiNode->oidlen, smiNode->oid, SMI_RENDER_ALL),
+#else
+					g_strdup (smiRenderOID(smiNode->oidlen, smiNode->oid, SMI_RENDER_ALL)),
+#endif
 					HFILL }};
 
 				oid_data->value_hfid = -1;