summaryrefslogtreecommitdiff
path: root/epan/proto.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/epan/proto.c b/epan/proto.c
index f3f803ffaa..6c552ca1b4 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -4913,6 +4913,13 @@ proto_get_next_protocol(void **cookie)
return protocol->proto_id;
}
+/* XXX: Unfortunately certain functions in proto_hier_tree_model.c
+ assume that the cookie stored by
+ proto_get_(first|next)_protocol_field() will never have a
+ value of NULL. So, to preserve this semantic, the cookie value
+ below is adjusted so that the cookie value stored is 1 + the
+ current (zero-based) array index.
+*/
header_field_info *
proto_get_first_protocol_field(const int proto_id, void **cookie)
{
@@ -4921,7 +4928,7 @@ proto_get_first_protocol_field(const int proto_id, void **cookie)
if ((protocol == NULL) || (protocol->fields->len == 0))
return NULL;
- *cookie = GINT_TO_POINTER(0);
+ *cookie = GUINT_TO_POINTER(0 + 1);
return (header_field_info *)g_ptr_array_index(protocol->fields, 0);
}
@@ -4929,14 +4936,14 @@ header_field_info *
proto_get_next_protocol_field(const int proto_id, void **cookie)
{
protocol_t *protocol = find_protocol_by_id(proto_id);
- guint i = GPOINTER_TO_INT(*cookie);
+ guint i = GPOINTER_TO_UINT(*cookie) - 1;
i++;
if (i >= protocol->fields->len)
return NULL;
- *cookie = GINT_TO_POINTER(i);
+ *cookie = GUINT_TO_POINTER(i + 1);
return (header_field_info *)g_ptr_array_index(protocol->fields, i);
}