diff options
author | Michael Mann <mmann78@netscape.net> | 2017-05-26 09:03:25 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-05-28 15:12:28 +0000 |
commit | 827cb68298032a3e3970fbaf9c3378822c43bd00 (patch) | |
tree | f170b44c73ca4c610e0dbb515bff2c789dcbbe02 /epan/proto.c | |
parent | 3ae77557af651938c34c752f62531a6b4c8e1309 (diff) |
proto_tree_add_bytes_format[_value] can handle NULL trees
v2.3.0rc0-3618-gd962e7ae71 tried to simplify logic, but missed
use of TRY_TO_FAKE_THIS_REPR. Create a "friendlier" version
TRY_TO_FAKE_THIS_REPR_NESTED which allows for the "base"
proto_tree_add_xxx to be called in proto_tree_add_xxx_format[_value]
functions.
Bug: 13736
Change-Id: I98883ad4581d2327edb8da5efd8ef8a89b55e3d0
Reviewed-on: https://code.wireshark.org/review/21764
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/proto.c')
-rw-r--r-- | epan/proto.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/epan/proto.c b/epan/proto.c index c2c0401f34..c14110f7e5 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -170,6 +170,13 @@ struct ptvcursor { * items string representation */ \ return; \ } +/* Similar to above, but allows a NULL tree */ +#define TRY_TO_FAKE_THIS_REPR_NESTED(pi) \ + if ((pi == NULL) || (!(PTREE_DATA(pi)->visible))) { \ + /* If the tree (GUI) isn't visible it's pointless for us to generate the protocol \ + * items string representation */ \ + return pi; \ + } static const char *hf_try_val_to_str(guint32 value, const header_field_info *hfinfo); static const char *hf_try_val64_to_str(guint64 value, const header_field_info *hfinfo); @@ -3323,6 +3330,8 @@ proto_tree_add_bytes_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb, pi = proto_tree_add_bytes(tree, hfindex, tvb, start, length, start_ptr); + TRY_TO_FAKE_THIS_REPR_NESTED(pi); + va_start(ap, format); proto_tree_set_representation_value(pi, format, ap); va_end(ap); @@ -3343,7 +3352,7 @@ proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, pi = proto_tree_add_bytes(tree, hfindex, tvb, start, length, start_ptr); - TRY_TO_FAKE_THIS_REPR(pi); + TRY_TO_FAKE_THIS_REPR_NESTED(pi); va_start(ap, format); proto_tree_set_representation(pi, format, ap); |