diff options
author | sahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7> | 2005-07-24 02:43:41 +0000 |
---|---|---|
committer | sahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7> | 2005-07-24 02:43:41 +0000 |
commit | e481ef87e942fea88b394a7e0108f8cd4efe83c8 (patch) | |
tree | d22834fc143b9ed887fac9996a48a5849e57454a /epan/dissectors | |
parent | eb4fb56b0cf11a096ff0470ae85b2882cf27167a (diff) |
convert some uses of tvb_get_string() to ep_tvb_get_string()
there was at least one obvious memleak in one of the uses of tvb_get_string()
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@15027 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/packet-3g-a11.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-afp.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-aim-messaging.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-aim.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-ansi_a.c | 15 | ||||
-rw-r--r-- | epan/dissectors/packet-atalk.c | 9 | ||||
-rw-r--r-- | epan/dissectors/packet-bacapp.c | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-dsi.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-fix.c | 9 | ||||
-rw-r--r-- | epan/dissectors/packet-gtp.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-icep.c | 17 |
11 files changed, 24 insertions, 59 deletions
diff --git a/epan/dissectors/packet-3g-a11.c b/epan/dissectors/packet-3g-a11.c index c077a54aa9..550c213b47 100644 --- a/epan/dissectors/packet-3g-a11.c +++ b/epan/dissectors/packet-3g-a11.c @@ -390,10 +390,9 @@ dissect_a11_radius( tvbuff_t *tvb, int offset, proto_tree *tree, int app_len) /**** ad-hoc ***/ if(radius_type == 31) { - str_val = tvb_get_string(tvb,offset+2,radius_len-2); + str_val = ep_tvb_get_string(tvb,offset+2,radius_len-2); proto_tree_add_text(radius_tree, tvb, offset, radius_len, "MSID: %s", str_val); - g_free(str_val); } else if (radius_type == 46) { @@ -479,11 +478,10 @@ dissect_a11_radius( tvbuff_t *tvb, int offset, proto_tree *tree, int app_len) a11_airlink_types,"Unknown")); break; case ATTR_TYPE_STR: - str_val = tvb_get_string(tvb,offset+radius_offset+2,attribute_len-2); + str_val = ep_tvb_get_string(tvb,offset+radius_offset+2,attribute_len-2); proto_tree_add_text(radius_tree, tvb, offset+radius_offset, attribute_len, "3GPP2: %s (%s)", attrs[attribute_type].attrname, str_val); - g_free(str_val); break; case ATTR_TYPE_NULL: break; diff --git a/epan/dissectors/packet-afp.c b/epan/dissectors/packet-afp.c index 2344de22da..a518940ba6 100644 --- a/epan/dissectors/packet-afp.c +++ b/epan/dissectors/packet-afp.c @@ -1597,7 +1597,7 @@ name_in_bitmap(tvbuff_t *tvb, gint offset, guint16 bitmap, int isdir) tp_ofs = nameoff +org_offset; len = tvb_get_guint8(tvb, tp_ofs); tp_ofs++; - name = tvb_get_string(tvb, tp_ofs, len); + name = ep_tvb_get_string(tvb, tp_ofs, len); return name; } offset += 2; @@ -1635,7 +1635,7 @@ name_in_bitmap(tvbuff_t *tvb, gint offset, guint16 bitmap, int isdir) tp_ofs = nameoff +org_offset +4; len16 = tvb_get_ntohs(tvb, tp_ofs); tp_ofs += 2; - name = tvb_get_string(tvb, tp_ofs, len16); + name = ep_tvb_get_string(tvb, tp_ofs, len16); return name; } } @@ -2064,7 +2064,6 @@ loop_record(tvbuff_t *tvb, proto_tree *ptree, gint offset, } if (name) { item = proto_tree_add_text(ptree, tvb, offset, size, "%s", name); - g_free(name); } else { item = proto_tree_add_text(ptree, tvb, offset, size, "line %d", i+1); diff --git a/epan/dissectors/packet-aim-messaging.c b/epan/dissectors/packet-aim-messaging.c index 1cd415b625..92131fc0d9 100644 --- a/epan/dissectors/packet-aim-messaging.c +++ b/epan/dissectors/packet-aim-messaging.c @@ -410,7 +410,7 @@ static int dissect_aim_rendezvous_extended_message(tvbuff_t *tvb, proto_tree *ms proto_tree_add_item(msg_tree, hf_aim_rendezvous_extended_data_message_priority_code, tvb, offset, 2, TRUE); offset+=2; text_length = tvb_get_letohs(tvb, offset); proto_tree_add_item(msg_tree, hf_aim_rendezvous_extended_data_message_text_length, tvb, offset, 2, TRUE); offset+=2; - text = tvb_get_string(tvb, offset, text_length); + text = ep_tvb_get_string(tvb, offset, text_length); proto_tree_add_text(msg_tree, tvb, offset, text_length, "Text: %s", text); offset+=text_length; offset = tvb->length; diff --git a/epan/dissectors/packet-aim.c b/epan/dissectors/packet-aim.c index 9b587cbf93..fe2857874a 100644 --- a/epan/dissectors/packet-aim.c +++ b/epan/dissectors/packet-aim.c @@ -1114,9 +1114,8 @@ int dissect_aim_tlv_value_string (proto_item *ti, guint16 valueid _U_, tvbuff_t gint string_len; string_len = tvb_length(tvb); - buf = tvb_get_string(tvb, 0, string_len); + buf = ep_tvb_get_string(tvb, 0, string_len); proto_item_set_text(ti, "Value: %s", format_text(buf, string_len)); - g_free(buf); return string_len; } @@ -1205,14 +1204,13 @@ int dissect_aim_tlv_value_messageblock (proto_item *ti, guint16 valueid _U_, tvb offset += 2; /* The actual message */ - buf = tvb_get_string(tvb, offset, blocklen - 4 ); + buf = ep_tvb_get_string(tvb, offset, blocklen - 4 ); proto_item_set_text(ti, "Message: %s", format_text(buf, blocklen - 4)); proto_tree_add_item(entry, hf_aim_messageblock_message, tvb, offset, blocklen-4, FALSE); offset += tvb_length_remaining(tvb, offset); - g_free(buf); } return offset; diff --git a/epan/dissectors/packet-ansi_a.c b/epan/dissectors/packet-ansi_a.c index dd4757a0fd..8b7d4fba66 100644 --- a/epan/dissectors/packet-ansi_a.c +++ b/epan/dissectors/packet-ansi_a.c @@ -1417,11 +1417,10 @@ elem_mid(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint len, gchar *add_ a_bigbuf[0] = Dgt_msid.out[(oct & 0xf0) >> 4]; curr_offset++; - poctets = tvb_get_string(tvb, curr_offset, len - (curr_offset - offset)); + poctets = ep_tvb_get_string(tvb, curr_offset, len - (curr_offset - offset)); my_dgt_tbcd_unpack(&a_bigbuf[1], poctets, len - (curr_offset - offset), &Dgt_msid); - g_free(poctets); proto_tree_add_string_format(tree, ((oct & 0x07) == 1) ? hf_ansi_a_min : hf_ansi_a_imsi, @@ -2746,7 +2745,7 @@ elem_clg_party_ascii_num(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint curr_offset++; } - poctets = tvb_get_string(tvb, curr_offset, len - (curr_offset - offset)); + poctets = ep_tvb_get_string(tvb, curr_offset, len - (curr_offset - offset)); proto_tree_add_string_format(tree, hf_ansi_a_clg_party_ascii_num, tvb, curr_offset, len - (curr_offset - offset), @@ -2757,7 +2756,6 @@ elem_clg_party_ascii_num(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint curr_offset += len - (curr_offset - offset); sprintf(add_string, " - (%s)", poctets); - g_free(poctets); EXTRANEOUS_DATA_CHECK(len, curr_offset - offset); @@ -3258,11 +3256,10 @@ elem_cld_party_bcd_num(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint le curr_offset++; - poctets = tvb_get_string(tvb, curr_offset, len - (curr_offset - offset)); + poctets = ep_tvb_get_string(tvb, curr_offset, len - (curr_offset - offset)); my_dgt_tbcd_unpack(a_bigbuf, poctets, len - (curr_offset - offset), &Dgt_tbcd); - g_free(poctets); proto_tree_add_string_format(tree, hf_ansi_a_cld_party_bcd_num, tvb, curr_offset, len - (curr_offset - offset), @@ -3396,11 +3393,10 @@ elem_clg_party_bcd_num(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint le curr_offset++; } - poctets = tvb_get_string(tvb, curr_offset, len - (curr_offset - offset)); + poctets = ep_tvb_get_string(tvb, curr_offset, len - (curr_offset - offset)); my_dgt_tbcd_unpack(a_bigbuf, poctets, len - (curr_offset - offset), &Dgt_tbcd); - g_free(poctets); proto_tree_add_string_format(tree, hf_ansi_a_clg_party_bcd_num, tvb, curr_offset, len - (curr_offset - offset), @@ -5286,7 +5282,7 @@ elem_cld_party_ascii_num(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint curr_offset++; - poctets = tvb_get_string(tvb, curr_offset, len - (curr_offset - offset)); + poctets = ep_tvb_get_string(tvb, curr_offset, len - (curr_offset - offset)); proto_tree_add_string_format(tree, hf_ansi_a_cld_party_ascii_num, tvb, curr_offset, len - (curr_offset - offset), @@ -5297,7 +5293,6 @@ elem_cld_party_ascii_num(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint curr_offset += len - (curr_offset - offset); sprintf(add_string, " - (%s)", poctets); - g_free(poctets); EXTRANEOUS_DATA_CHECK(len, curr_offset - offset); diff --git a/epan/dissectors/packet-atalk.c b/epan/dissectors/packet-atalk.c index 7f48b4e346..72cfa3b48f 100644 --- a/epan/dissectors/packet-atalk.c +++ b/epan/dissectors/packet-atalk.c @@ -518,14 +518,13 @@ static int dissect_pascal_string(tvbuff_t *tvb, int offset, proto_tree *tree, * code, we could perhaps avoid allocating and freeing * this string buffer. */ - tmp = tvb_get_string(tvb, offset, len); + tmp = ep_tvb_get_string(tvb, offset, len); item = proto_tree_add_string(tree, hf_index, tvb, offset-1, len+1, tmp); subtree = proto_item_add_subtree(item, ett_pstring); proto_tree_add_text(subtree, tvb, offset-1, 1, "Length: %d", len); proto_tree_add_text(subtree, tvb, offset, len, "Data: %s", tmp); - g_free(tmp); } offset += len; @@ -1053,9 +1052,8 @@ dissect_asp_reply_get_status(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * break; case 4: /* DNS */ if (len > 2) { - tmp = tvb_get_string(tvb, ofs +2, len -2); + tmp = ep_tvb_get_string(tvb, ofs +2, len -2); ti = proto_tree_add_text(adr_tree, tvb, ofs, len, "dns %s", tmp); - g_free(tmp); break; } /* else fall to default malformed record */ @@ -1092,14 +1090,13 @@ dissect_asp_reply_get_status(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * ofs = utf_ofs; ulen = tvb_get_ntohs(tvb, ofs); - tmp = tvb_get_string(tvb, ofs + 2, ulen); + tmp = ep_tvb_get_string(tvb, ofs + 2, ulen); ti = proto_tree_add_text(tree, tvb, ofs, ulen +2, "UTF8 server name: %s", tmp); sub_tree = proto_item_add_subtree(ti, ett_asp_utf8_name); proto_tree_add_uint(sub_tree, hf_asp_server_utf8_name_len, tvb, ofs, 2, ulen); ofs += 2; proto_tree_add_string(sub_tree, hf_asp_server_utf8_name, tvb, ofs, ulen, tmp); ofs += ulen; - g_free(tmp); } /* FIXME: offset is not updated */ return offset; diff --git a/epan/dissectors/packet-bacapp.c b/epan/dissectors/packet-bacapp.c index 766711e9d6..d46bfa20a6 100644 --- a/epan/dissectors/packet-bacapp.c +++ b/epan/dissectors/packet-bacapp.c @@ -2189,7 +2189,7 @@ fCharacterString (tvbuff_t *tvb, proto_tree *tree, guint offset, guint8 *label) * other dissectors need to handle various * character encodings. */ - str_val = tvb_get_string(tvb, offset, l); + str_val = ep_tvb_get_string(tvb, offset, l); /** this decoding may be not correct for multi-byte characters, Lka */ switch (character_set) { case 0x00: /* ANSI_X3.4 */ @@ -2215,7 +2215,6 @@ fCharacterString (tvbuff_t *tvb, proto_tree *tree, guint offset, guint8 *label) break; } proto_tree_add_text(tree, tvb, offset, l, "%s'%s'", LABEL(label), out); - g_free(str_val); lvt-=l; offset+=l; } while (lvt > 0); diff --git a/epan/dissectors/packet-dsi.c b/epan/dissectors/packet-dsi.c index 04f1415bb8..75c1eaed99 100644 --- a/epan/dissectors/packet-dsi.c +++ b/epan/dissectors/packet-dsi.c @@ -414,10 +414,9 @@ dissect_dsi_reply_get_status(tvbuff_t *tvb, proto_tree *tree, gint offset) case 4: /* DNS */ case 5: /* SSH tunnel */ if (len > 2) { - tmp = tvb_get_string(tvb, ofs +2, len -2); + tmp = ep_tvb_get_string(tvb, ofs +2, len -2); ti = proto_tree_add_text(adr_tree, tvb, ofs, len, "%s: %s", (type==4)?"dns":"ssh tunnel", tmp); - g_free(tmp); break; } else { @@ -468,14 +467,13 @@ dissect_dsi_reply_get_status(tvbuff_t *tvb, proto_tree *tree, gint offset) ofs = utf_ofs; ulen = tvb_get_ntohs(tvb, ofs); - tmp = tvb_get_string(tvb, ofs + 2, ulen); + tmp = ep_tvb_get_string(tvb, ofs + 2, ulen); ti = proto_tree_add_text(tree, tvb, ofs, ulen + 2, "UTF8 server name: %s", tmp); sub_tree = proto_item_add_subtree(ti, ett_dsi_utf8_name); proto_tree_add_uint(sub_tree, hf_dsi_utf8_server_name_len, tvb, ofs, 2, ulen); ofs += 2; proto_tree_add_string(sub_tree, hf_dsi_utf8_server_name, tvb, ofs, ulen, tmp); ofs += ulen; - g_free(tmp); } return offset; diff --git a/epan/dissectors/packet-fix.c b/epan/dissectors/packet-fix.c index aeacf739ca..beae7737b9 100644 --- a/epan/dissectors/packet-fix.c +++ b/epan/dissectors/packet-fix.c @@ -868,9 +868,8 @@ dissect_fix(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (check_col(pinfo->cinfo, COL_INFO)) { - value = tvb_get_string(tvb, value_offset, value_len); + value = ep_tvb_get_string(tvb, value_offset, value_len); col_add_fstr(pinfo->cinfo, COL_INFO, "%s", (char *)g_datalist_get_data(&msg_types, value)); - g_free(value); } /* In the interest of speed, if "tree" is NULL, don't do any work not @@ -926,11 +925,10 @@ dissect_fix(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) packet. */ return TRUE; } - tag_str = tvb_get_string(tvb, field_offset, tag_len); + tag_str = ep_tvb_get_string(tvb, field_offset, tag_len); tag = atoi(tag_str); - g_free(tag_str); - value = tvb_get_string(tvb, value_offset, value_len); + value = ep_tvb_get_string(tvb, value_offset, value_len); switch(tag) { case 1: /* Field Account */ @@ -2916,7 +2914,6 @@ dissect_fix(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) field_offset = offset = ctrla_offset + 1; ctrla_offset = tvb_find_guint8(tvb, field_offset, -1, 0x01); - g_free(value); tag_str = NULL; } } diff --git a/epan/dissectors/packet-gtp.c b/epan/dissectors/packet-gtp.c index d713e6850f..794cce01cf 100644 --- a/epan/dissectors/packet-gtp.c +++ b/epan/dissectors/packet-gtp.c @@ -3144,7 +3144,7 @@ decode_apn(tvbuff_t *tvb, int offset, guint16 length, proto_tree *tree) { name_len = tvb_get_guint8 (tvb, offset); if (name_len < 0x20) { - apn = tvb_get_string(tvb, offset + 1, length - 1); + apn = ep_tvb_get_string(tvb, offset + 1, length - 1); for (;;) { if (name_len >= length - 1) break; tmp = name_len; @@ -3152,10 +3152,9 @@ decode_apn(tvbuff_t *tvb, int offset, guint16 length, proto_tree *tree) { apn[tmp] = '.'; } } else - apn = tvb_get_string(tvb, offset, length); + apn = ep_tvb_get_string(tvb, offset, length); proto_tree_add_string (tree, hf_gtp_apn, tvb, offset, length, apn); - g_free(apn); } } diff --git a/epan/dissectors/packet-icep.c b/epan/dissectors/packet-icep.c index af9a36d9e8..2c5b51cbd2 100644 --- a/epan/dissectors/packet-icep.c +++ b/epan/dissectors/packet-icep.c @@ -158,8 +158,6 @@ static packet_info *mypinfo; * This function dissects an "Ice string", adds hf to "tree" and returns consumed * bytes in "*consumed", if errors "*consumed" is -1. * - * Memory for the new string "*dest" is obtained with g_malloc, and caller - * is responsible for it (i.e. don't forget to g_free() it if you pass *dest != NULL). * "*dest" is a null terminated version of the dissected Ice string. */ static void dissect_ice_string(proto_tree *tree, int hf_icep, @@ -258,7 +256,7 @@ static void dissect_ice_string(proto_tree *tree, int hf_icep, if ( Size != 0 ) { - s = tvb_get_string(tvb, offset, Size); + s = ep_tvb_get_string(tvb, offset, Size); if (tree && add_hf) proto_tree_add_string(tree, hf_icep, tvb, offset, Size, s); } else { @@ -270,8 +268,6 @@ static void dissect_ice_string(proto_tree *tree, int hf_icep, if ( dest != NULL ) *dest = s; - else - g_free(s); offset += Size; (*consumed) += Size; @@ -484,7 +480,6 @@ static void dissect_ice_context(proto_tree *tree, tvbuff_t *tvb, guint32 offset, if ( consumed_key == -1 ) { (*consumed) = -1; - g_free(str_key); return; } @@ -496,8 +491,6 @@ static void dissect_ice_context(proto_tree *tree, tvbuff_t *tvb, guint32 offset, if ( consumed_value == -1 ) { (*consumed) = -1; - g_free(str_value); - g_free(str_key); return; } @@ -513,8 +506,6 @@ static void dissect_ice_context(proto_tree *tree, tvbuff_t *tvb, guint32 offset, str_key, str_value); } - g_free(str_value); - g_free(str_key); } } @@ -733,8 +724,6 @@ static void dissect_icep_request_common(tvbuff_t *tvb, guint32 offset, col_append_fstr(mypinfo->cinfo, COL_INFO, " %s.%s()", namestr, opstr); } - g_free(opstr); - g_free(namestr); opstr = NULL; namestr = NULL; } @@ -790,10 +779,6 @@ static void dissect_icep_request_common(tvbuff_t *tvb, guint32 offset, error: (*total_consumed) = -1; - if (namestr) - g_free(namestr); - if (opstr) - g_free(opstr); } |