aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-dcm.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2005-04-17 22:08:22 +0000
committerGerald Combs <gerald@wireshark.org>2005-04-17 22:08:22 +0000
commit5caccdd94ec8d6508699965ed5e1d4b5d807c1c4 (patch)
tree766e0e3785928fdec364bc003481efc2fcc5c515 /epan/dissectors/packet-dcm.c
parentf315d0976ce3a633d362fbdd49f1811cf6195fcf (diff)
downloadwireshark-5caccdd94ec8d6508699965ed5e1d4b5d807c1c4.tar.gz
wireshark-5caccdd94ec8d6508699965ed5e1d4b5d807c1c4.tar.bz2
wireshark-5caccdd94ec8d6508699965ed5e1d4b5d807c1c4.zip
Change a bunch of instances where we manually fetch a string and call
proto_tree_add_string() to just use proto_tree_add_item(). Add a note about a memory leak. Fixes bug 65. svn path=/trunk/; revision=14117
Diffstat (limited to 'epan/dissectors/packet-dcm.c')
-rw-r--r--epan/dissectors/packet-dcm.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/epan/dissectors/packet-dcm.c b/epan/dissectors/packet-dcm.c
index d284cc0fe7..d90a5122d0 100644
--- a/epan/dissectors/packet-dcm.c
+++ b/epan/dissectors/packet-dcm.c
@@ -629,26 +629,20 @@ dissect_dcm_assoc(dcmState_t *dcm_data, proto_item *ti, tvbuff_t *tvb, int offse
offset += 4;
switch (id) {
case 0x10: /* App context */
- name = g_malloc(1 + len);
- tvb_memcpy(tvb, name, offset, len);
- *(name + len) = 0;
- proto_tree_add_string(dcm_tree, hf_dcm_pdi_name, tvb, offset, len, name);
- g_free(name);
+ proto_tree_add_item(dcm_tree, hf_dcm_pdi_name, tvb, offset, len, FALSE);
offset += len;
break;
case 0x30: /* Abstract syntax */
- dcm_data->last->abs = name = g_malloc(1 + len);
- tvb_memcpy(tvb, name, offset, len);
- *(name + len) = 0;
- proto_tree_add_string(dcm_tree, hf_dcm_pdi_syntax, tvb, offset, len, name);
+ proto_tree_add_item(dcm_tree, hf_dcm_pdi_syntax, tvb, offset, len, FALSE);
offset += len;
break;
case 0x40: /* Transfer syntax */
- name = g_malloc(1 + len);
- tvb_memcpy(tvb, name, offset, len);
- *(name + len) = 0;
- proto_tree_add_string(dcm_tree, hf_dcm_pdi_syntax, tvb, offset, len, name);
- if (reply && di && di->valid) dcm_setSyntax(di, name);
+ proto_tree_add_item(dcm_tree, hf_dcm_pdi_syntax, tvb, offset, len, FALSE);
+ if (reply && di && di->valid) {
+ /* XXX - This is a memory leak. */
+ name = tvb_get_string(tvb, offset, len);
+ dcm_setSyntax(di, name);
+ }
reply = 0;
offset += len;
break;
@@ -692,19 +686,11 @@ dissect_dcm_assoc(dcmState_t *dcm_data, proto_item *ti, tvbuff_t *tvb, int offse
offset += len;
break;
case 0x52: /* UID? */
- name = g_malloc(1 + len);
- tvb_memcpy(tvb, name, offset, len);
- *(name + len) = 0;
- proto_tree_add_string(dcm_tree, hf_dcm_impl, tvb, offset, len, name);
- g_free(name);
+ proto_tree_add_item(dcm_tree, hf_dcm_impl, tvb, offset, len, FALSE);
offset += len;
break;
case 0x55: /* version? */
- name = g_malloc(1 + len);
- tvb_memcpy(tvb, name, offset, len);
- *(name + len) = 0;
- proto_tree_add_string(dcm_tree, hf_dcm_vers, tvb, offset, len, name);
- g_free(name);
+ proto_tree_add_item(dcm_tree, hf_dcm_vers, tvb, offset, len, FALSE);
offset += len;
break;
default: