Fix some memory leaks when extracting a string from TVB

Change-Id: If3970a20045d84200924f89ac467c4eb0206cb11
Reviewed-on: https://code.wireshark.org/review/10446
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
Pascal Quantin 2015-09-08 22:44:34 +02:00
parent 61ea02b145
commit 322e09676c
3 changed files with 9 additions and 11 deletions

View File

@ -637,7 +637,7 @@ dissect_attribute_entries(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
for (i_entry = 0; i_entry < count; ++i_entry) {
attribute_id = tvb_get_ntohl(tvb, offset);
value_length = tvb_get_ntohs(tvb, offset + 4 + 2);
value = tvb_get_string_enc(NULL, tvb, offset + 4 + 2 + 2, value_length, ENC_ASCII);
value = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 4 + 2 + 2, value_length, ENC_ASCII);
if (attribute_id == 0x01) col_append_fstr(pinfo->cinfo, COL_INFO, " - Title: \"%s\"", value);
@ -675,7 +675,7 @@ dissect_item_mediaplayer(tvbuff_t *tvb, proto_tree *tree, gint offset)
item_length = tvb_get_ntohs(tvb, offset + 1);
displayable_name_length = tvb_get_ntohs(tvb, offset + 1 + 2 + 1 + 1 + 4 + 16 + 1 + 2);
displayable_name = tvb_get_string_enc(NULL, tvb, offset + 1 + 2 + 1 + 1 + 4 + 16 + 1 + 2 + 2, displayable_name_length, ENC_ASCII);
displayable_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1 + 2 + 1 + 1 + 4 + 16 + 1 + 2 + 2, displayable_name_length, ENC_ASCII);
pitem = proto_tree_add_none_format(tree, hf_btavrcp_player_item, tvb, offset, 1 + 2 + item_length, "Player: %s", displayable_name);
ptree = proto_item_add_subtree(pitem, ett_btavrcp_player);
@ -837,7 +837,7 @@ dissect_item_media_element(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
item_length = tvb_get_ntohs(tvb, offset + 1);
displayable_name_length = tvb_get_ntohs(tvb, offset + 1 + 2 + 8 + 1 + 2);
displayable_name = tvb_get_string_enc(NULL, tvb, offset + 1 + 2 + 8 + 1 + 2 + 2, displayable_name_length, ENC_ASCII);
displayable_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1 + 2 + 8 + 1 + 2 + 2, displayable_name_length, ENC_ASCII);
pitem = proto_tree_add_none_format(tree, hf_btavrcp_item , tvb, offset, 1 + 2 + item_length, "Element: %s", displayable_name);
ptree = proto_item_add_subtree(pitem, ett_btavrcp_element);
@ -889,7 +889,7 @@ dissect_item_folder(tvbuff_t *tvb, proto_tree *tree, gint offset)
item_length = tvb_get_ntohs(tvb, offset + 1);
displayable_name_length = tvb_get_ntohs(tvb, offset + 1 + 2 + 8 + 1 + 1 + 2);
displayable_name = tvb_get_string_enc(NULL, tvb, offset + 1 + 2 + 8 + 1 + 1 + 2 + 2, displayable_name_length, ENC_ASCII);
displayable_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1 + 2 + 8 + 1 + 1 + 2 + 2, displayable_name_length, ENC_ASCII);
pitem = proto_tree_add_none_format(tree, hf_btavrcp_folder, tvb, offset, 1 + 2 + item_length, "Folder : %s", displayable_name);
ptree = proto_item_add_subtree(pitem, ett_btavrcp_folder);
@ -1933,7 +1933,7 @@ dissect_browsing(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
folder_name_length = tvb_get_ntohs(tvb, offset);
offset += 2;
proto_tree_add_item(ptree, hf_btavrcp_folder_name, tvb, offset, folder_name_length, ENC_NA);
folder_name = tvb_get_string_enc(NULL, tvb, offset, folder_name_length, ENC_ASCII);
folder_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, folder_name_length, ENC_ASCII);
offset += folder_name_length;
proto_item_append_text(pitem, "%s/", folder_name);
col_append_fstr(pinfo->cinfo, COL_INFO, "%s/", folder_name);

View File

@ -249,7 +249,7 @@ dissect_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint8 *id;
proto_tree_add_item(tree, hf_bthcrp_control_1284_id, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII | ENC_NA);
id = tvb_get_string_enc(NULL, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII);
id = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII);
col_append_fstr(pinfo->cinfo, COL_INFO, " - 1284 ID: %s", id);
offset += tvb_reported_length_remaining(tvb, offset);
}

View File

@ -1919,7 +1919,7 @@ dissect_fhandle_data_GLUSTER(tvbuff_t* tvb, packet_info *pinfo _U_, proto_tree *
if (fhlen != 36)
return;
ident = tvb_get_string_enc(NULL, tvb, offset, 4, ENC_ASCII);
ident = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 4, ENC_ASCII);
if (strncmp(":OGL", ident, 4))
return;
offset += 4;
@ -2124,9 +2124,8 @@ dissect_fhandle_data(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *
guint8 *fh_array;
proto_item *fh_item = NULL;
fh_array = tvb_get_string_enc(NULL, tvb, offset, fhlen, ENC_ASCII);
fh_array = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, fhlen, ENC_ASCII);
fhhash = crc32_ccitt(fh_array, fhlen);
g_free(fh_array);
if (hidden) {
fh_item = proto_tree_add_uint(tree, hf_nfs_fh_hash, NULL, 0,
@ -7626,9 +7625,8 @@ dissect_nfs4_stateid(tvbuff_t *tvb, int offset, proto_tree *tree, guint16 *hash)
newftree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_nfs4_stateid, &fitem, "stateid");
sidh_array = tvb_get_string_enc(NULL, tvb, offset, 16, ENC_ASCII);
sidh_array = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 16, ENC_ASCII);
sid_hash = crc16_ccitt(sidh_array, 16);
g_free(sidh_array);
sh_item = proto_tree_add_uint(newftree, hf_nfs4_stateid_hash, tvb, offset, 16, sid_hash);
PROTO_ITEM_SET_GENERATED(sh_item);