diff options
author | Dario Lombardo <lomato@gmail.com> | 2016-04-08 10:49:18 +0200 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-04-13 02:19:39 +0000 |
commit | 4d5caf316f98a7a4884ed60ac7b697aad1a66ccf (patch) | |
tree | 1c3b9444aa98d7be5b0bbb464038e414b4c153e0 /epan/dissectors/packet-6lowpan.c | |
parent | cf6501eb45408c83467160c8ed026c6aab347642 (diff) |
6lowpan: change malloc to wmem_alloc.
Change-Id: Iae9c52571457baccdce9ae0586ee223a08ec7597
Reviewed-on: https://code.wireshark.org/review/14890
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-6lowpan.c')
-rw-r--r-- | epan/dissectors/packet-6lowpan.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/epan/dissectors/packet-6lowpan.c b/epan/dissectors/packet-6lowpan.c index 7329119fe8..b89bc8f54e 100644 --- a/epan/dissectors/packet-6lowpan.c +++ b/epan/dissectors/packet-6lowpan.c @@ -498,7 +498,7 @@ static gboolean lowpan_dlsrc_to_ifcid (packet_info *pinfo, guint8 *ifcid); static gboolean lowpan_dldst_to_ifcid (packet_info *pinfo, guint8 *ifcid); static void lowpan_addr16_to_ifcid (guint16 addr, guint8 *ifcid); static void lowpan_addr16_with_panid_to_ifcid(guint16 panid, guint16 addr, guint8 *ifcid); -static tvbuff_t * lowpan_reassemble_ipv6 (tvbuff_t *tvb, struct ip6_hdr * ipv6, struct lowpan_nhdr * nhdr_list); +static tvbuff_t * lowpan_reassemble_ipv6 (tvbuff_t *tvb, packet_info *pinfo, struct ip6_hdr * ipv6, struct lowpan_nhdr * nhdr_list); static guint8 lowpan_parse_nhc_proto (tvbuff_t *tvb, gint offset); /* Context table helpers */ @@ -835,14 +835,13 @@ lowpan_dldst_to_ifcid(packet_info *pinfo, guint8 *ifcid) *--------------------------------------------------------------- */ static tvbuff_t * -lowpan_reassemble_ipv6(tvbuff_t *tvb, struct ip6_hdr *ipv6, struct lowpan_nhdr *nhdr_list) +lowpan_reassemble_ipv6(tvbuff_t *tvb, packet_info *pinfo, struct ip6_hdr *ipv6, struct lowpan_nhdr *nhdr_list) { gint length = 0; gint reported = 0; guint8 * buffer; guint8 * cursor; struct lowpan_nhdr *nhdr; - tvbuff_t *ret; /* Compute the real and reported lengths. */ for (nhdr = nhdr_list; nhdr; nhdr = nhdr->next) { @@ -852,7 +851,7 @@ lowpan_reassemble_ipv6(tvbuff_t *tvb, struct ip6_hdr *ipv6, struct lowpan_nhdr * ipv6->ip6_plen = g_ntohs(reported); /* Allocate a buffer for the packet and copy in the IPv6 header. */ - buffer = (guint8 *)g_malloc(length + sizeof(struct ip6_hdr)); + buffer = (guint8 *)wmem_alloc(pinfo->pool, length + sizeof(struct ip6_hdr)); memcpy(buffer, ipv6, sizeof(struct ip6_hdr)); cursor = buffer + sizeof(struct ip6_hdr); @@ -863,9 +862,7 @@ lowpan_reassemble_ipv6(tvbuff_t *tvb, struct ip6_hdr *ipv6, struct lowpan_nhdr * }; /* Return the reassembled packet. */ - ret = tvb_new_child_real_data(tvb, buffer, length + (int)sizeof(struct ip6_hdr), reported + (int)sizeof(struct ip6_hdr)); - tvb_set_free_cb(ret, g_free); - return ret; + return tvb_new_child_real_data(tvb, buffer, length + (int)sizeof(struct ip6_hdr), reported + (int)sizeof(struct ip6_hdr)); } /* lowpan_reassemble_ipv6 */ /*FUNCTION:------------------------------------------------------ @@ -1389,7 +1386,7 @@ dissect_6lowpan_hc1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint dg } /* Link the reassembled tvbuff together. */ - ipv6_tvb = lowpan_reassemble_ipv6(tvb, &ipv6, nhdr_list); + ipv6_tvb = lowpan_reassemble_ipv6(tvb, pinfo, &ipv6, nhdr_list); /* Add a new data source for it. */ add_new_data_source(pinfo, ipv6_tvb, "Decompressed 6LoWPAN HC1"); @@ -1818,7 +1815,7 @@ dissect_6lowpan_iphc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint d *===================================================== */ /* Reassemble the IPv6 packet. */ - ipv6_tvb = lowpan_reassemble_ipv6(tvb, &ipv6, nhdr_list); + ipv6_tvb = lowpan_reassemble_ipv6(tvb, pinfo, &ipv6, nhdr_list); /* Add a new data source for it. */ add_new_data_source(pinfo, ipv6_tvb, "Decompressed 6LoWPAN IPHC"); |