summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2015-09-08 22:44:34 +0200
committerPascal Quantin <pascal.quantin@gmail.com>2015-09-09 09:36:10 +0000
commitdecbe9409f6881e3d029b4f88c3c450e5c5bc7be (patch)
tree3404fc8e025509433601b2deed22432ef0b2f167
parent80a097cb6b941336d1d864824df6928616d0d6fb (diff)
downloadwireshark-decbe9409f6881e3d029b4f88c3c450e5c5bc7be.tar.gz
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> (cherry picked from commit 322e09676c26c4e02cb92779691ddd93e3e7056b) Reviewed-on: https://code.wireshark.org/review/10448
-rw-r--r--epan/dissectors/packet-btavrcp.c10
-rw-r--r--epan/dissectors/packet-bthcrp.c2
-rw-r--r--epan/dissectors/packet-nfs.c8
3 files changed, 9 insertions, 11 deletions
diff --git a/epan/dissectors/packet-btavrcp.c b/epan/dissectors/packet-btavrcp.c
index 22fcdfbde3..98223092d2 100644
--- a/epan/dissectors/packet-btavrcp.c
+++ b/epan/dissectors/packet-btavrcp.c
@@ -634,7 +634,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(NULL, tvb, offset + 4 + 2 + 2, value_length);
+ value = tvb_get_string(wmem_packet_scope(), tvb, offset + 4 + 2 + 2, value_length);
if (attribute_id == 0x01) col_append_fstr(pinfo->cinfo, COL_INFO, " - Title: \"%s\"", value);
@@ -672,7 +672,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(NULL, tvb, offset + 1 + 2 + 1 + 1 + 4 + 16 + 1 + 2 + 2, displayable_name_length);
+ displayable_name = tvb_get_string(wmem_packet_scope(), tvb, offset + 1 + 2 + 1 + 1 + 4 + 16 + 1 + 2 + 2, displayable_name_length);
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);
@@ -834,7 +834,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(NULL, tvb, offset + 1 + 2 + 8 + 1 + 2 + 2, displayable_name_length);
+ displayable_name = tvb_get_string(wmem_packet_scope(), tvb, offset + 1 + 2 + 8 + 1 + 2 + 2, displayable_name_length);
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);
@@ -886,7 +886,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(NULL, tvb, offset + 1 + 2 + 8 + 1 + 1 + 2 + 2, displayable_name_length);
+ displayable_name = tvb_get_string(wmem_packet_scope(), tvb, offset + 1 + 2 + 8 + 1 + 1 + 2 + 2, displayable_name_length);
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);
@@ -1909,7 +1909,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(NULL, tvb, offset, folder_name_length);
+ folder_name = tvb_get_string(wmem_packet_scope(), tvb, offset, folder_name_length);
offset += folder_name_length;
proto_item_append_text(pitem, "%s/", folder_name);
col_append_fstr(pinfo->cinfo, COL_INFO, "%s/", folder_name);
diff --git a/epan/dissectors/packet-bthcrp.c b/epan/dissectors/packet-bthcrp.c
index 8089139b7b..3c39cf5bba 100644
--- a/epan/dissectors/packet-bthcrp.c
+++ b/epan/dissectors/packet-bthcrp.c
@@ -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, -1, ENC_ASCII | ENC_NA);
- id = tvb_get_string(NULL, tvb, offset, tvb_length_remaining(tvb, offset));
+ id = tvb_get_string(wmem_packet_scope(), tvb, offset, tvb_length_remaining(tvb, offset));
col_append_fstr(pinfo->cinfo, COL_INFO, " - 1284 ID: %s", id);
offset += tvb_length_remaining(tvb, offset);
}
diff --git a/epan/dissectors/packet-nfs.c b/epan/dissectors/packet-nfs.c
index 2340bb418a..8df917de07 100644
--- a/epan/dissectors/packet-nfs.c
+++ b/epan/dissectors/packet-nfs.c
@@ -2187,7 +2187,7 @@ dissect_fhandle_data_GLUSTER(tvbuff_t* tvb, packet_info *pinfo _U_, proto_tree *
if (fhlen != 36)
return;
- ident = tvb_get_string(NULL, tvb, offset, 4);
+ ident = tvb_get_string(wmem_packet_scope(), tvb, offset, 4);
if (strncmp(":OGL", ident, 4))
return;
offset += 4;
@@ -2371,9 +2371,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(NULL, tvb, offset, fhlen);
+ fh_array = tvb_get_string(wmem_packet_scope(), tvb, offset, fhlen);
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,
@@ -8028,9 +8027,8 @@ dissect_nfs4_stateid(tvbuff_t *tvb, int offset, proto_tree *tree, guint16 *hash)
newftree = proto_item_add_subtree(fitem, ett_nfs4_stateid);
}
- sidh_array = tvb_get_string(NULL, tvb, offset, 16);
+ sidh_array = tvb_get_string(wmem_packet_scope(), tvb, offset, 16);
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);