diff options
author | Dario Lombardo <lomato@gmail.com> | 2016-02-16 14:19:42 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2016-02-17 14:14:40 +0000 |
commit | 7382b026255620b80397da338c2c6dde78f78673 (patch) | |
tree | 0a8bcaccc034e42d6438353fc217f302802854b1 /epan/dissectors/packet-cip.c | |
parent | 6671b0dea8a4b724814b698f7418d4c5d07c461a (diff) |
cip: fix a leak
Change g_list into wmem_list to solve the leak. Leak found by valgrind.
==14755== 3,384 (504 direct, 2,880 indirect) bytes in 21 blocks are definitely lost in loss record 3,380 of 3,418
==14755== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14755== by 0xA806610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==14755== by 0xA81C22D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==14755== by 0xA7FD4F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==14755== by 0x67CD825: build_get_attr_all_table (packet-cip.c:5402)
==14755== by 0x67CD825: proto_register_cip (packet-cip.c:8067)
==14755== by 0x71C83F9: register_all_protocols (register.c:229)
==14755== by 0x65F14D7: proto_init (proto.c:521)
==14755== by 0x65CF961: epan_init (epan.c:126)
==14755== by 0x1153F0: main (tshark.c:1220)
Change-Id: I9c25ee5b5bf04b9afb8b0bf22bb6f3d7022bf4d3
Reviewed-on: https://code.wireshark.org/review/13969
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-cip.c')
-rw-r--r-- | epan/dissectors/packet-cip.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/epan/dissectors/packet-cip.c b/epan/dissectors/packet-cip.c index 6690a95aec..4a2ef18e13 100644 --- a/epan/dissectors/packet-cip.c +++ b/epan/dissectors/packet-cip.c @@ -42,6 +42,7 @@ #include <epan/expert.h> #include <epan/prefs.h> #include <epan/proto_data.h> +#include <wmem/wmem_list.h> #include "packet-cip.h" #include "packet-cipsafety.h" #include "packet-mbtcp.h" @@ -5336,7 +5337,7 @@ typedef struct cip_gaa_key { } cip_gaa_key_t; typedef struct cip_gaa_val { - GList *attributes; + wmem_list_t *attributes; } cip_gaa_val_t; static wmem_map_t *cip_gaa_hashtable = NULL; @@ -5392,6 +5393,7 @@ static void build_get_attr_all_table(void) { new_key = (cip_gaa_key_t*)wmem_memdup(wmem_epan_scope(), &key, sizeof(cip_gaa_key_t)); gaa_val = wmem_new0(wmem_epan_scope(), cip_gaa_val_t); + gaa_val->attributes = wmem_list_new(wmem_epan_scope()); wmem_map_insert(cip_gaa_hashtable, new_key, gaa_val ); last_attribute_index = -1; @@ -5399,7 +5401,7 @@ static void build_get_attr_all_table(void) if ((pattr->gaa_index >= 0) && (pattr->gaa_index > last_attribute_index)) { - gaa_val->attributes = g_list_append(gaa_val->attributes, pattr); + wmem_list_append(gaa_val->attributes, pattr); last_attribute_index = pattr->gaa_index; } } @@ -5417,7 +5419,7 @@ dissect_cip_get_attribute_all_rsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree proto_tree *att_tree; cip_gaa_key_t key; cip_gaa_val_t *gaa_val; - GList *attribute_list; + wmem_list_frame_t* attribute_list; key.cip_class = req_data->iClass; key.class_instance = (req_data->iInstance == 0); @@ -5429,11 +5431,11 @@ dissect_cip_get_attribute_all_rsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree return; } - for (attribute_list = g_list_first(gaa_val->attributes); + for (attribute_list = wmem_list_head(gaa_val->attributes); (attribute_list != NULL); - attribute_list = g_list_next(attribute_list)) + attribute_list = wmem_list_frame_next(attribute_list)) { - attr = (attribute_info_t *)attribute_list->data; + attr = (attribute_info_t *)wmem_list_frame_data(attribute_list); len_remain = tvb_reported_length_remaining(tvb, offset); /* If there are no more attributes defined or there is no data left. */ |