Wireshark-dev: [Wireshark-dev] Problem with proto_tree_add_item...
From: "Tobias Erichsen" <t.erichsen@xxxxxx>
Date: Sun, 15 Feb 2009 23:38:39 +0100
Hi everyone,

I seem to have a little problem with calling proto_tree_add_item.  On some packets,
when I click on the entry to expand the tree, Wireshark crashes.  If I don't insert
those add_items, everything is fine...

Some sniplets of the code are below.

Has anyone possibly got any insights what I am doing wrong?

Best regards,
Tobias






#define RTP_MIDI_CS_FLAG_B				0x80
#define RTP_MIDI_CS_FLAG_J				0x40
#define RTP_MIDI_CS_FLAG_Z				0x20
#define RTP_MIDI_CS_FLAG_P				0x10

static int hf_rtp_midi_bflag				= -1;
static int hf_rtp_midi_jflag				= -1;
static int hf_rtp_midi_zflag				= -1;
static int hf_rtp_midi_pflag				= -1;


static const value_string rtp_midi_cs_flag_b[] =
{
	{ 0,"Short Header: 1 octet" },
	{ 1,"Long Header: 2 octets" },
	{ 0,NULL },
};

static const value_string rtp_midi_cs_flag_j[] =
{
	{ 0,"No Journal present" },
	{ 1,"Journal present" },
	{ 0,NULL },
};

static const value_string rtp_midi_cs_flag_z[] =
{
	{ 0,"No Delta-Time for first MIDI-command" },
	{ 1,"Delta-Time present for first MIDI-command" },
	{ 0,NULL },
};

static const value_string rtp_midi_cs_flag_p[] =
{
	{ 0,"Status byte was present in original MIDI-command" },
	{ 1,"Status byte was NOT present in original MIDI-command" },
	{ 0,NULL },
};



static hf_register_info hf[] = {
	{
	&hf_rtp_midi_bflag,
	{
		"B-Flag",
		"rtpmidi.b_flag",
		FT_BOOLEAN,
		8,
		VALS(rtp_midi_cs_flag_b),
		RTP_MIDI_CS_FLAG_B,
		"", HFILL
	}
},
{
	&hf_rtp_midi_jflag,
	{
		"J-Flag",
		"rtpmidi.j_flag",
		FT_BOOLEAN,
		8,
		VALS(rtp_midi_cs_flag_j),
		RTP_MIDI_CS_FLAG_J,
		"", HFILL
	}
},
{
	&hf_rtp_midi_zflag,
	{
		"Z-Flag",
		"rtpmidi.z_flag",
		FT_BOOLEAN,
		8,
		VALS(rtp_midi_cs_flag_z),
		RTP_MIDI_CS_FLAG_Z,
		"", HFILL
	}
},
{
	&hf_rtp_midi_pflag,
	{
		"P-Flag",
		"rtpmidi.p_flag",
		FT_BOOLEAN,
		8,
		VALS(rtp_midi_cs_flag_p),
		RTP_MIDI_CS_FLAG_P,
		"", HFILL
	}
},
};



/* Decode those four flags */
proto_tree_add_item ( rtp_midi_tree, hf_rtp_midi_bflag, tvb, offset, 1, 0 );
/* if I return here, no problems... if I add next line -> Wireshark crashes... */
proto_tree_add_item ( rtp_midi_tree, hf_rtp_midi_jflag, tvb, offset, 1, 0 );
proto_tree_add_item ( rtp_midi_tree, hf_rtp_midi_zflag, tvb, offset, 1, 0 );
proto_tree_add_item ( rtp_midi_tree, hf_rtp_midi_pflag, tvb, offset, 1, 0 );
-- 
Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL 
für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a