From 13221904228eedc6d75455433fb7beb77ab30cba Mon Sep 17 00:00:00 2001 From: Bill Meier Date: Mon, 30 Jun 2014 01:48:16 -0400 Subject: Fix Bug #10238: Display filter expression dialog items do not expand/display properly. Unfortunately, certain proto_hier_tree_model.c functions assume/require that a cookie generated by proto_(first|next)_protocol_field() will never have a NULL value. Bug introduced in gd47ae54. Change-Id: I42763d02f700e15ca9b3ab9980943d4f8d933ca9 Reviewed-on: https://code.wireshark.org/review/2712 Reviewed-by: Evan Huus (cherry picked from commit 9cf40b67b258616c248569b74685693f14a0aab3) Reviewed-on: https://code.wireshark.org/review/2715 --- epan/proto.c | 13 ++++++++++--- 1 file 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); } -- cgit v1.2.1