From 6bbd17bcf906f3db833c482de3461a1bc5e5154e Mon Sep 17 00:00:00 2001 From: Jeff Morriss Date: Sun, 18 Oct 2009 20:13:56 +0000 Subject: Don't se_alloc() the conversation structure which contains pointers to two g_hash_tables that we then try to free in ros_reinit(). Instead, g_malloc() the conversation structure and free it (along with the hash tables) in the reinit function. svn path=/trunk/; revision=30601 --- asn1/ros/packet-ros-template.c | 48 ++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'asn1') diff --git a/asn1/ros/packet-ros-template.c b/asn1/ros/packet-ros-template.c index 63cd2caa72..6e5b6bb5c1 100644 --- a/asn1/ros/packet-ros-template.c +++ b/asn1/ros/packet-ros-template.c @@ -103,7 +103,7 @@ register_ros_oid_dissector_handle(const char *oid, dissector_handle_t dissector, void register_ros_protocol_info(const char *oid, const ros_info_t *rinfo, int proto _U_, const char *name, gboolean uses_rtse) { - g_hash_table_insert(protocol_table, (gpointer)oid, (gpointer)rinfo); + g_hash_table_insert(protocol_table, (gpointer)oid, (gpointer)rinfo); g_hash_table_insert(oid_table, (gpointer)oid, (gpointer)name); if(!uses_rtse) @@ -115,10 +115,10 @@ static new_dissector_t ros_lookup_opr_dissector(gint32 opcode, const ros_opr_t * { /* we don't know what order asn2wrs/module definition is, so ... */ if(operations) { - for(;operations->arg_pdu != (new_dissector_t)(-1); operations++) - if(operations->opcode == opcode) + for(;operations->arg_pdu != (new_dissector_t)(-1); operations++) + if(operations->opcode == opcode) return argument ? operations->arg_pdu : operations->res_pdu; - + } return NULL; } @@ -128,7 +128,7 @@ static new_dissector_t ros_lookup_err_dissector(gint32 errcode, const ros_err_t /* we don't know what order asn2wrs/module definition is, so ... */ if(errors) { for(;errors->err_pdu != (new_dissector_t) (-1); errors++) { - if(errors->errcode == errcode) + if(errors->errcode == errcode) return errors->err_pdu; } } @@ -164,8 +164,8 @@ static gboolean ros_try_string(const char *oid, tvbuff_t *tvb, packet_info *pinf if((session->ros_op & ROS_OP_PDU_MASK) == ROS_OP_ERROR) opcode = err_ros_bind; else - opcode = op_ros_bind; - } else + opcode = op_ros_bind; + } else /* otherwise just take the opcode */ opcode = session->ros_op & ROS_OP_OPCODE_MASK; @@ -173,15 +173,15 @@ static gboolean ros_try_string(const char *oid, tvbuff_t *tvb, packet_info *pinf lookup = rinfo->opr_code_strings; switch(session->ros_op & ROS_OP_PDU_MASK) { - case ROS_OP_ARGUMENT: + case ROS_OP_ARGUMENT: opdissector = ros_lookup_opr_dissector(opcode, rinfo->opr_code_dissectors, TRUE); suffix = "_argument"; break; - case ROS_OP_RESULT: + case ROS_OP_RESULT: opdissector = ros_lookup_opr_dissector(opcode, rinfo->opr_code_dissectors, FALSE); suffix = "_result"; break; - case ROS_OP_ERROR: + case ROS_OP_ERROR: opdissector = ros_lookup_err_dissector(opcode, rinfo->err_code_dissectors); lookup = rinfo->err_code_strings; break; @@ -198,7 +198,7 @@ static gboolean ros_try_string(const char *oid, tvbuff_t *tvb, packet_info *pinf if(suffix) col_append_str(pinfo->cinfo, COL_INFO, suffix); } - + offset = (*opdissector)(tvb, pinfo, ros_tree); return TRUE; @@ -225,7 +225,7 @@ call_ros_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *p dissect_unknown_ber(pinfo, next_tvb, offset, next_tree); } - /*XXX until we change the #.REGISTER signature for _PDU()s + /*XXX until we change the #.REGISTER signature for _PDU()s * into new_dissector_t we have to do this kludge with * manually step past the content in the ANY type. */ @@ -296,7 +296,7 @@ ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui rcr.req_frame=0; rcr.rep_frame=pinfo->fd->num; } - + rcrp=g_hash_table_lookup(ros_info->matched, &rcr); if(rcrp) { @@ -304,7 +304,7 @@ ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui rcrp->is_request=rcr.is_request; } else { - + /* we haven't found a match - try and match it up */ if(isInvoke) { @@ -320,7 +320,7 @@ ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui if(rcrp){ g_hash_table_remove(ros_info->unmatched, rcrp); } - + /* if we cant reuse the old one, grab a new chunk */ if(!rcrp){ rcrp=se_alloc(sizeof(ros_call_response_t)); @@ -367,7 +367,7 @@ ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui PROTO_ITEM_SET_GENERATED (item); } } - + return rcrp; } @@ -397,7 +397,7 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) if(parent_tree){ proto_tree_add_text(parent_tree, tvb, offset, -1, "Internal error:can't get application context from ACSE dissector."); - } + } return ; } else { session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) ); @@ -426,12 +426,12 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) /* No. Attach that information to the conversation. */ - ros_info = se_alloc(sizeof(ros_conv_info_t)); + ros_info = g_malloc(sizeof(ros_conv_info_t)); ros_info->matched=g_hash_table_new(ros_info_hash_matched, ros_info_equal_matched); ros_info->unmatched=g_hash_table_new(ros_info_hash_unmatched, ros_info_equal_unmatched); - + conversation_add_proto_data(conversation, proto_ros, ros_info); - + ros_info->next = ros_info_items; ros_info_items = ros_info; } @@ -469,11 +469,17 @@ ros_reinit(void) ros_conv_info_t *ros_info; /* Free up state attached to the ros_info structures */ - for (ros_info = ros_info_items; ros_info != NULL; ros_info = ros_info->next) { + for (ros_info = ros_info_items; ros_info != NULL; ) { + ros_conv_info_t *last; + g_hash_table_destroy(ros_info->matched); ros_info->matched=NULL; g_hash_table_destroy(ros_info->unmatched); ros_info->unmatched=NULL; + + last = ros_info; + ros_info = ros_info->next; + g_free(last); } ros_info_items = NULL; -- cgit v1.2.3