From f0dbb28854346970f4329413c9bae8a212d95836 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 6 Dec 2016 13:37:45 -0800 Subject: Throw in another tweak to check for uninitialized cops_call_t structures. Temporariy add a "magic" field, initialize it when we allocate it, and whenever we fetch a structure from the array, make sure the "magic" field has the right value. (If this all turns out to be a valgrind bug, I'm not going to be very happy.) Change-Id: I29becc715367fdc305504b38d48be05dc516132a Reviewed-on: https://code.wireshark.org/review/19128 Reviewed-by: Guy Harris --- epan/dissectors/packet-cops.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'epan/dissectors/packet-cops.c') diff --git a/epan/dissectors/packet-cops.c b/epan/dissectors/packet-cops.c index b727c6b5f1..10a663d7ba 100644 --- a/epan/dissectors/packet-cops.c +++ b/epan/dissectors/packet-cops.c @@ -805,6 +805,9 @@ typedef struct _cops_conv_info_t { typedef struct _cops_call_t { +#if 1 +guint32 magic; +#endif guint8 op_code; gboolean solicited; guint32 req_num; @@ -1053,6 +1056,10 @@ dissect_cops_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data if (!pinfo->fd->flags.visited) { cops_call = wmem_new0(wmem_file_scope(), cops_call_t); + cops_call = wmem_new(wmem_file_scope(), cops_call_t); +#if 1 +cops_call->magic = 0xbeeff00d; +#endif cops_call->op_code = op_code; cops_call->solicited = is_solicited; cops_call->req_num = pinfo->num; @@ -1063,6 +1070,9 @@ dissect_cops_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data else { for (i=0; i < pdus_array->len; i++) { cops_call = (cops_call_t*)g_ptr_array_index(pdus_array, i); +#if 1 +DISSECTOR_ASSERT(cops_call->magic == 0xbeeff00d); +#endif if ( cops_call->req_num == pinfo->num && cops_call->rsp_num != 0) { ti = proto_tree_add_uint_format(cops_tree, hf_cops_response_in, tvb, 0, 0, cops_call->rsp_num, @@ -1082,6 +1092,9 @@ dissect_cops_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data if (!pinfo->fd->flags.visited) { for (i=0; i < pdus_array->len; i++) { cops_call = (cops_call_t*)g_ptr_array_index(pdus_array, i); +#if 1 +DISSECTOR_ASSERT(cops_call->magic == 0xbeeff00d); +#endif if (nstime_cmp(&pinfo->abs_ts, &cops_call->req_time) <= 0 || cops_call->rsp_num != 0) continue; @@ -1172,6 +1185,9 @@ dissect_cops_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data else { for (i=0; i < pdus_array->len; i++) { cops_call = (cops_call_t*)g_ptr_array_index(pdus_array, i); +#if 1 +DISSECTOR_ASSERT(cops_call->magic == 0xbeeff00d); +#endif if ( cops_call->rsp_num == pinfo->num ) { ti = proto_tree_add_uint_format(cops_tree, hf_cops_response_to, tvb, 0, 0, cops_call->req_num, "Response to a request in frame %u", cops_call->req_num); -- cgit v1.2.3