/* if the representation of the item has already been set, use that;
else we have to allocate a block to put the text into */
- if( ie_finfo -> rep != NULL )
+ if( ie_finfo && ie_finfo->rep != NULL )
proto_item_set_text(ti, "Information Element: %s",
ie_finfo->rep->representation);
else {
will still have somewhere to attach to \
or else filtering will not work (they would be ignored since tree\
would be NULL). \
- DONT try to fake a node where PTREE_FINFO(tree) is NULL \
- since dissectors that want to do proto_item_set_len() or \
- other operations that dereference this would crash. \
We fake FT_PROTOCOL unless some clients have requested us \
not to do so. \
*/ \
return(NULL); \
PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo); \
if(!(PTREE_DATA(tree)->visible)){ \
- if(PTREE_FINFO(tree)){ \
if((hfinfo->ref_count == HF_REF_TYPE_NONE) \
&& (hfinfo->type!=FT_PROTOCOL || \
PTREE_DATA(tree)->fake_protocols)){ \
/* just return tree back to the caller */\
return tree; \
} \
- } \
}
static gboolean
return;
fi = PITEM_FINFO(pi);
+ DISSECTOR_ASSERT(fi && "proto_tree_set_visible(tree, TRUE) should have been called previously");
+
hfinfo = fi->hfinfo;
if (hfinfo->type == FT_PROTOCOL) {
/* TRY_TO_FAKE_THIS_ITEM() speed optimization: silently skip */
{
int ret; /*tmp return value */
field_info *fi = PITEM_FINFO(pi);
- header_field_info *hf = fi->hfinfo;
+ header_field_info *hf;
+
+ DISSECTOR_ASSERT(fi);
+
+ hf = fi->hfinfo;
if (!PROTO_ITEM_IS_HIDDEN(pi)) {
ITEM_LABEL_NEW(fi->rep);
int ret; /*tmp return value */
field_info *fi = PITEM_FINFO(pi);
+ DISSECTOR_ASSERT(fi);
+
if (!PROTO_ITEM_IS_HIDDEN(pi)) {
ITEM_LABEL_NEW(fi->rep);
ret = g_vsnprintf(fi->rep->representation, ITEM_LABEL_LENGTH,
}
fi = PITEM_FINFO(pi);
+ if (fi==NULL)
+ return;
if(fi->rep){
ITEM_LABEL_FREE(fi->rep);
if (pi == NULL)
return;
+
fi = PITEM_FINFO(pi);
+ if (fi == NULL)
+ return;
+
DISSECTOR_ASSERT(length >= 0);
fi->length = length;
if (pi == NULL)
return;
+
fi = PITEM_FINFO(pi);
+ if (fi == NULL)
+ return;
+
end += TVB_RAW_OFFSET(tvb);
DISSECTOR_ASSERT(end >= fi->start);
fi->length = end - fi->start;
proto_item_get_len(proto_item *pi)
{
field_info *fi = PITEM_FINFO(pi);
- return fi->length;
+ return fi ? fi->length : -1;
}
return FALSE;
}
-
-
proto_tree*
proto_tree_create_root(void)
{
if (!pi)
return(NULL);
- fi = PITEM_FINFO(pi);
DISSECTOR_ASSERT(idx >= 0 && idx < num_tree_types);
+
+ fi = PITEM_FINFO(pi);
+ if (!fi)
+ return (proto_tree*) pi;
+
fi->tree_type = idx;
return (proto_tree*) pi;
void
proto_tree_move_item(proto_tree *tree, proto_item *fixed_item, proto_item *item_to_move)
{
+ /* This function doesn't generate any values. It only reorganizes the prococol tree
+ * so we can bail out immediately if it isn't visible. */
+ if (!tree || !PTREE_DATA(tree)->visible)
+ return;
+
DISSECTOR_ASSERT(item_to_move->parent == tree);
DISSECTOR_ASSERT(fixed_item->parent == tree);
return;
fi = PTREE_FINFO(tree);
+ if (fi == NULL)
+ return;
+
start += TVB_RAW_OFFSET(tvb);
DISSECTOR_ASSERT(start >= 0);
DISSECTOR_ASSERT(length >= 0);
const gchar *name;
int ret; /*tmp return value */
+ if (!fi) {
+ if (label_str)
+ label_str[0]= '\0';
+ /* XXX: Check validity of hfinfo->type */
+ return;
+ }
+
switch(hfinfo->type) {
case FT_NONE:
case FT_PROTOCOL:
/** The protocol field is actually a URL */
#define FI_URL 0x00000004
-
/** convenience macro to get field_info.flags */
-#define FI_GET_FLAG(fi, flag) (fi->flags & flag)
+#define FI_GET_FLAG(fi, flag) ((fi) ? (fi->flags & flag) : 0)
/** convenience macro to set field_info.flags */
-#define FI_SET_FLAG(fi, flag) (fi->flags = fi->flags | flag)
+#define FI_SET_FLAG(fi, flag) ((fi) ? (fi->flags = fi->flags | flag) : 0)
/** One of these exists for the entire protocol tree. Each proto_node
* in the protocol tree points to the same copy. */
guint8 c_char;
size_t c_match = 0;
+ g_assert(fi && "dissection with an invisible proto tree?");
+
if (mdata->frame_matched) {
/* We already had a match; don't bother doing any more work. */
return;
/* If an expert item was passed then build the filter string */
if (expert_data->pitem) {
char *filter;
-
+
+ g_assert(PITEM_FINFO(expert_data->pitem));
filter = proto_construct_match_selected_string(PITEM_FINFO(expert_data->pitem), NULL);
if (filter != NULL)
procedure->fvalue_value = g_string_chunk_insert(err->text, filter);
GtkTreeIter iter;
GtkTreePath *path;
+ g_assert(fi && "dissection with an invisible proto tree?");
+
if (PROTO_ITEM_IS_HIDDEN(node) && !prefs.display_hidden_proto_items)
return;
finfo = PNODE_FINFO(ptree_node);
+ g_assert(finfo && "Caller passed top of the protocol tree. Expected child node");
+
if (hfinformation==(finfo->hfinfo)) {
hfssrc = proto_registrar_get_byname(proto_field);
if (hfssrc == NULL)
/* display the TLV name and display the value in hex. Highlight type, length, and value. */
tlv_item = proto_tree_add_item(tree, hfindex, tvb, start, tlv_value_length, little_endian);
+
+ if (!PITEM_FINFO(tlv_item))
+ return tree;
+
/* Correct the highlighting. */
PITEM_FINFO(tlv_item)->start -= tlv_val_offset;
PITEM_FINFO(tlv_item)->length += tlv_val_offset;
message = se_strdup_vprintf(format, ap);
va_end(ap);
tlv_item = proto_tree_add_protocol_format(tree, hfindex, tvb, start, length, "%s", message);
+
+ if (!PITEM_FINFO(tlv_item))
+ return tree;
+
/* Correct the highlighting. */
PITEM_FINFO(tlv_item)->start -= tlv_val_offset;
PITEM_FINFO(tlv_item)->length += tlv_val_offset;
gchar label_str[ITEM_LABEL_LENGTH];
gchar *label_ptr;
+ g_assert(fi && "dissection with an invisible proto tree?");
+
/* Don't print invisible entries. */
if (PROTO_ITEM_IS_HIDDEN(node))
return;
char *dfilter_string;
size_t chop_len;
int i;
+ gboolean wrap_in_fake_protocol;
+
+ g_assert(fi && "dissection with an invisible proto tree?");
/* Will wrap up top-level field items inside a fake protocol wrapper to
preserve the PDML schema */
- gboolean wrap_in_fake_protocol =
+ wrap_in_fake_protocol =
(((fi->hfinfo->type != FT_PROTOCOL) ||
(fi->hfinfo->id == proto_data)) &&
(pdata->level == 0));
call_data = data;
fi = PNODE_FINFO(node);
+ g_assert(fi && "dissection with an invisible proto tree?");
+
field_index = g_hash_table_lookup(call_data->fields->field_indicies, fi->hfinfo->abbrev);
if(NULL != field_index) {
const gchar* value;
GNode *stat_node;
finfo = PNODE_FINFO(ptree_node);
- g_assert(finfo);
+ /* We don't fake protocol nodes we expect them to have a field_info */
+ g_assert(finfo && "dissection with faked proto tree?");
/* If the field info isn't related to a protocol but to a field,
* don't count them, as they don't belong to any protocol.