From 1edbd5a875af00d1972eb24c43d94f2b6c5220f9 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 19 Apr 2015 14:26:54 -0700 Subject: [PATCH] Don't use proto_tree_add_uint() to add FT_BOOLEAN values. In proto_item_add_bitmask_tree(), if use_value is true, base the routine we use to add the item to the tree on the type of the field being added. Also, use DISSECTOR_ASSERT_NOT_REACHED(), not g_assert_not_reached(), to catch types that aren't integral or Boolean. Change-Id: I6ff9867bddcae16ddf8b689b48fdc93c6f949105 Reviewed-on: https://code.wireshark.org/review/8127 Reviewed-by: Guy Harris --- epan/proto.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/epan/proto.c b/epan/proto.c index ddad3a7eeb..5cb226f967 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -8100,10 +8100,37 @@ proto_item_add_bitmask_tree(proto_item *item, tvbuff_t *tvb, const int offset, if (use_value) { - if (len <= 4) + switch (hf->type) { + case FT_INT8: + case FT_UINT8: + case FT_INT16: + case FT_UINT16: + case FT_INT24: + case FT_UINT24: + case FT_INT32: + case FT_UINT32: proto_tree_add_uint(tree, **fields, tvb, offset, len, (guint32)value); - else + break; + + case FT_INT40: + case FT_UINT40: + case FT_INT48: + case FT_UINT48: + case FT_INT56: + case FT_UINT56: + case FT_INT64: + case FT_UINT64: proto_tree_add_uint64(tree, **fields, tvb, offset, len, value); + break; + + case FT_BOOLEAN: + proto_tree_add_boolean(tree, **fields, tvb, offset, len, (guint32)value); + break; + + default: + DISSECTOR_ASSERT_NOT_REACHED(); + break; + } } else { @@ -8184,7 +8211,8 @@ proto_item_add_bitmask_tree(proto_item *item, tvbuff_t *tvb, const int offset, } break; default: - g_assert_not_reached(); + DISSECTOR_ASSERT_NOT_REACHED(); + break; } fields++;