summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2016-04-21 17:26:38 +0200
committerMichael Mann <mmann78@netscape.net>2016-04-21 18:29:17 +0000
commit91cae7cf412043d5c76d4bab6fbcf69a04a553dd (patch)
tree7ced7273ce347f9cfaf291808a24ef1ce78e9793
parent2048bc225875257bbf8810e4e103324629e3693a (diff)
downloadwireshark-91cae7cf412043d5c76d4bab6fbcf69a04a553dd.tar.gz
Do not mix wmem and glib allocators
Change-Id: I4bf861ed9e6b767341f2cbd4e926606d4919f2ef Reviewed-on: https://code.wireshark.org/review/15041 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/dissectors/asn1/ldap/ldap.cnf4
-rw-r--r--epan/dissectors/asn1/ldap/packet-ldap-template.c3
-rw-r--r--epan/dissectors/packet-dcerpc-spoolss.c34
-rw-r--r--epan/dissectors/packet-ldap.c13
-rw-r--r--epan/dissectors/packet-xml.c3
-rw-r--r--epan/dissectors/packet-xtp.c29
6 files changed, 23 insertions, 63 deletions
diff --git a/epan/dissectors/asn1/ldap/ldap.cnf b/epan/dissectors/asn1/ldap/ldap.cnf
index 13f03bcac3..452c6261f1 100644
--- a/epan/dissectors/asn1/ldap/ldap.cnf
+++ b/epan/dissectors/asn1/ldap/ldap.cnf
@@ -173,7 +173,7 @@ char *mechanism = NULL;
* different type and/or mechanism.
*/
if(!actx->pinfo->fd->flags.visited) {
- mechanism = tvb_get_string_enc(NULL, parameter_tvb, 0, tvb_reported_length_remaining(parameter_tvb,0), ENC_UTF_8|ENC_NA);
+ mechanism = tvb_get_string_enc(wmem_file_scope(), parameter_tvb, 0, tvb_reported_length_remaining(parameter_tvb,0), ENC_UTF_8|ENC_NA);
ldap_info->first_auth_frame = 0; /* not known until we see the bind reply */
/*
* If the mechanism in this request is an empty string (which is
@@ -182,7 +182,7 @@ char *mechanism = NULL;
* save this mechanism.
*/
if (mechanism != NULL) {
- g_free(ldap_info->auth_mech);
+ wmem_free(wmem_file_scope(), ldap_info->auth_mech);
ldap_info->auth_mech = mechanism;
}
}
diff --git a/epan/dissectors/asn1/ldap/packet-ldap-template.c b/epan/dissectors/asn1/ldap/packet-ldap-template.c
index cc9f2e6ebf..5efdfe1716 100644
--- a/epan/dissectors/asn1/ldap/packet-ldap-template.c
+++ b/epan/dissectors/asn1/ldap/packet-ldap-template.c
@@ -1114,7 +1114,7 @@ static void
&&(tvb_get_guint8(tvb, offset+4)==0x60) ){
ldap_info->auth_type=LDAP_AUTH_SASL;
ldap_info->first_auth_frame=pinfo->num;
- ldap_info->auth_mech=g_strdup("GSS-SPNEGO");
+ ldap_info->auth_mech=wmem_strdup(wmem_file_scope(), "GSS-SPNEGO");
doing_sasl_security=TRUE;
}
@@ -1900,7 +1900,6 @@ ldap_cleanup(void)
for (ldap_info = ldap_info_items; ldap_info != NULL; ) {
ldap_conv_info_t *next;
- g_free(ldap_info->auth_mech);
g_hash_table_destroy(ldap_info->matched);
g_hash_table_destroy(ldap_info->unmatched);
diff --git a/epan/dissectors/packet-dcerpc-spoolss.c b/epan/dissectors/packet-dcerpc-spoolss.c
index bf497fa03b..3327f8c9a9 100644
--- a/epan/dissectors/packet-dcerpc-spoolss.c
+++ b/epan/dissectors/packet-dcerpc-spoolss.c
@@ -708,7 +708,7 @@ dissect_printerdata_data(tvbuff_t *tvb, int offset,
switch(type) {
case DCERPC_REG_SZ: {
- char *data = tvb_get_string_enc(NULL, tvb, offset - size, size, ENC_UTF_16|ENC_LITTLE_ENDIAN);
+ char *data = tvb_get_string_enc(wmem_packet_scope(), tvb, offset - size, size, ENC_UTF_16|ENC_LITTLE_ENDIAN);
proto_item_append_text(item, ": %s", data);
@@ -720,8 +720,6 @@ dissect_printerdata_data(tvbuff_t *tvb, int offset,
offset - size, size, data);
PROTO_ITEM_SET_HIDDEN(hidden_item);
- g_free(data);
-
break;
}
case DCERPC_REG_DWORD: {
@@ -1093,19 +1091,17 @@ dissect_spoolss_uint16uni(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
remaining = tvb_reported_length_remaining(tvb, offset);
if (remaining <= 0) {
if (data)
- *data = g_strdup("");
+ *data = wmem_strdup(wmem_packet_scope(), "");
return offset;
}
- text = tvb_get_string_enc(NULL, tvb, offset, remaining, ENC_UTF_16|ENC_LITTLE_ENDIAN);
+ text = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, remaining, ENC_UTF_16|ENC_LITTLE_ENDIAN);
len = (int)strlen(text);
proto_tree_add_string(tree, hf_name, tvb, offset, len * 2, text);
if (data)
*data = text;
- else
- g_free(text);
return offset + (len + 1) * 2;
}
@@ -1681,7 +1677,7 @@ dissect_spoolss_relstr(tvbuff_t *tvb, int offset, packet_info *pinfo,
relstr_end = dissect_spoolss_uint16uni(
tvb, relstr_start, pinfo, NULL, drep, &text, hf_relative_string);
} else { /* relstr_offset == 0 is a NULL string */
- text = g_strdup("");
+ text = wmem_strdup(wmem_packet_scope(), "");
relstr_end = relstr_start;
}
@@ -1699,8 +1695,6 @@ dissect_spoolss_relstr(tvbuff_t *tvb, int offset, packet_info *pinfo,
if (data)
*data = text;
- else
- g_free(text);
return offset;
}
@@ -1736,7 +1730,7 @@ dissect_spoolss_relstrarray(tvbuff_t *tvb, int offset, packet_info *pinfo,
/*relstr_end = */dissect_spoolss_uint16uni(
tvb, relstr_start, pinfo, subtree, drep, &text, hf_relative_string);
else {
- text = g_strdup("NULL");
+ text = wmem_strdup(wmem_packet_scope(), "NULL");
/*relstr_end = offset;*/
}
@@ -1746,8 +1740,6 @@ dissect_spoolss_relstrarray(tvbuff_t *tvb, int offset, packet_info *pinfo,
if (data)
*data = text;
- else
- g_free(text);
return offset;
}
@@ -3369,7 +3361,6 @@ dissect_FORM_REL(tvbuff_t *tvb, int offset, packet_info *pinfo,
if (name) {
proto_item_append_text(item, ": %s", name);
- g_free(name);
}
offset = dissect_ndr_uint32(
@@ -3646,8 +3637,6 @@ SpoolssEnumPrinterData_r(tvbuff_t *tvb, int offset,
hidden_item = proto_tree_add_string(
tree, hf_printerdata_value, tvb, offset, 0, value);
PROTO_ITEM_SET_HIDDEN(hidden_item);
-
- g_free(value);
}
proto_item_set_len(value_item, value_len * 2 + 4);
@@ -4217,7 +4206,6 @@ dissect_spoolss_JOB_INFO_1(tvbuff_t *tvb, int offset, packet_info *pinfo,
struct_start, &document_name);
proto_item_append_text(item, ": %s", document_name);
- g_free(document_name);
offset = dissect_spoolss_relstr(
tvb, offset, pinfo, subtree, di, drep, hf_datatype,
@@ -4288,7 +4276,6 @@ dissect_spoolss_JOB_INFO_2(tvbuff_t *tvb, int offset, packet_info *pinfo,
struct_start, &document_name);
proto_item_append_text(item, ": %s", document_name);
- g_free(document_name);
offset = dissect_spoolss_relstr(
tvb, offset, pinfo, subtree, di, drep, hf_notifyname,
@@ -5485,7 +5472,7 @@ cb_notify_str_postprocess(packet_info *pinfo _U_,
len = tvb_get_letohl(tvb, start_offset);
- s = tvb_get_string_enc(NULL,
+ s = tvb_get_string_enc(wmem_packet_scope(),
tvb, start_offset + 4, (end_offset - start_offset - 4), ENC_UTF_16|ENC_LITTLE_ENDIAN);
/* Append string to upper-level proto_items */
@@ -5515,8 +5502,6 @@ cb_notify_str_postprocess(packet_info *pinfo _U_,
tree, hf_index, tvb, start_offset, len, s);
PROTO_ITEM_SET_HIDDEN(hidden_item);
}
-
- g_free(s);
}
/* Return the hf_index for a printer notify field. This is used to
@@ -6344,7 +6329,7 @@ dissect_spoolss_printer_enum_values(tvbuff_t *tvb, int offset,
if (val_len == 0) {
proto_tree_add_uint_format_value(subtree, hf_enumprinterdataex_value_null, tvb, start_offset + val_offset, 4, 0, "(null)");
- goto done;
+ return offset;
}
switch(val_type) {
@@ -6381,8 +6366,6 @@ dissect_spoolss_printer_enum_values(tvbuff_t *tvb, int offset,
proto_item_append_text(item, ", Value: %s", value);
- g_free(value);
-
break;
}
case DCERPC_REG_BINARY:
@@ -6403,9 +6386,6 @@ dissect_spoolss_printer_enum_values(tvbuff_t *tvb, int offset,
proto_tree_add_expert_format( subtree, pinfo, &ei_enumprinterdataex_value, tvb, start_offset + val_offset, val_len, "%s: unknown type %d", name, val_type);
}
- done:
- g_free(name);
-
return offset;
}
diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c
index 59ae2eba9a..8f8b90d461 100644
--- a/epan/dissectors/packet-ldap.c
+++ b/epan/dissectors/packet-ldap.c
@@ -1322,7 +1322,7 @@ char *mechanism = NULL;
* different type and/or mechanism.
*/
if(!actx->pinfo->fd->flags.visited) {
- mechanism = tvb_get_string_enc(NULL, parameter_tvb, 0, tvb_reported_length_remaining(parameter_tvb,0), ENC_UTF_8|ENC_NA);
+ mechanism = tvb_get_string_enc(wmem_file_scope(), parameter_tvb, 0, tvb_reported_length_remaining(parameter_tvb,0), ENC_UTF_8|ENC_NA);
ldap_info->first_auth_frame = 0; /* not known until we see the bind reply */
/*
* If the mechanism in this request is an empty string (which is
@@ -1331,7 +1331,7 @@ char *mechanism = NULL;
* save this mechanism.
*/
if (mechanism != NULL) {
- g_free(ldap_info->auth_mech);
+ wmem_free(wmem_file_scope(), ldap_info->auth_mech);
ldap_info->auth_mech = mechanism;
}
}
@@ -4033,7 +4033,7 @@ static void
&&(tvb_get_guint8(tvb, offset+4)==0x60) ){
ldap_info->auth_type=LDAP_AUTH_SASL;
ldap_info->first_auth_frame=pinfo->num;
- ldap_info->auth_mech=g_strdup("GSS-SPNEGO");
+ ldap_info->auth_mech=wmem_strdup(wmem_file_scope(), "GSS-SPNEGO");
doing_sasl_security=TRUE;
}
@@ -4819,7 +4819,6 @@ ldap_cleanup(void)
for (ldap_info = ldap_info_items; ldap_info != NULL; ) {
ldap_conv_info_t *next;
- g_free(ldap_info->auth_mech);
g_hash_table_destroy(ldap_info->matched);
g_hash_table_destroy(ldap_info->unmatched);
@@ -5674,7 +5673,7 @@ void proto_register_ldap(void) {
NULL, HFILL }},
/*--- End of included file: packet-ldap-hfarr.c ---*/
-#line 2190 "./asn1/ldap/packet-ldap-template.c"
+#line 2189 "./asn1/ldap/packet-ldap-template.c"
};
/* List of subtrees */
@@ -5748,7 +5747,7 @@ void proto_register_ldap(void) {
&ett_ldap_T_warning,
/*--- End of included file: packet-ldap-ettarr.c ---*/
-#line 2204 "./asn1/ldap/packet-ldap-template.c"
+#line 2203 "./asn1/ldap/packet-ldap-template.c"
};
/* UAT for header fields */
static uat_field_t custom_attribute_types_uat_fields[] = {
@@ -5918,7 +5917,7 @@ proto_reg_handoff_ldap(void)
/*--- End of included file: packet-ldap-dis-tab.c ---*/
-#line 2357 "./asn1/ldap/packet-ldap-template.c"
+#line 2356 "./asn1/ldap/packet-ldap-template.c"
}
diff --git a/epan/dissectors/packet-xml.c b/epan/dissectors/packet-xml.c
index 3bc13099e2..ca10bdb2d9 100644
--- a/epan/dissectors/packet-xml.c
+++ b/epan/dissectors/packet-xml.c
@@ -238,9 +238,8 @@ static gboolean dissect_xml_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *
return TRUE;
} else if (pref_heuristic_unicode) {
/* XXX - UCS-2, or UTF-16? */
- const guint8 *data_str = tvb_get_string_enc(NULL, tvb, 0, tvb_captured_length(tvb), ENC_UCS_2|ENC_LITTLE_ENDIAN);
+ const guint8 *data_str = tvb_get_string_enc(pinfo->pool, tvb, 0, tvb_captured_length(tvb), ENC_UCS_2|ENC_LITTLE_ENDIAN);
tvbuff_t *unicode_tvb = tvb_new_child_real_data(tvb, data_str, tvb_captured_length(tvb)/2, tvb_captured_length(tvb)/2);
- tvb_set_free_cb(unicode_tvb, g_free);
if (tvbparse_peek(tvbparse_init(unicode_tvb, 0, -1, NULL, want_ignore), want_heur)) {
add_new_data_source(pinfo, unicode_tvb, "UTF8");
dissect_xml(unicode_tvb, pinfo, tree, data);
diff --git a/epan/dissectors/packet-xtp.c b/epan/dissectors/packet-xtp.c
index 2f81a16cc5..2eeea7a0de 100644
--- a/epan/dissectors/packet-xtp.c
+++ b/epan/dissectors/packet-xtp.c
@@ -844,11 +844,8 @@ dissect_xtp_jcntl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
static void
dissect_xtp_diag(tvbuff_t *tvb, proto_tree *tree, guint32 offset) {
guint32 len = tvb_reported_length_remaining(tvb, offset);
- guint32 start = offset;
proto_item *ti;
proto_tree *xtp_subtree;
- struct xtp_diag diag[1];
- guint32 msg_len;
xtp_subtree = proto_tree_add_subtree(tree, tvb, offset, len, ett_xtp_diag, &ti, "Diagnostic Segment");
@@ -859,31 +856,17 @@ dissect_xtp_diag(tvbuff_t *tvb, proto_tree *tree, guint32 offset) {
return;
}
- /** parse **/
/* code(4) */
- diag->code = tvb_get_ntohl(tvb, offset);
+ proto_tree_add_item(xtp_subtree, hf_xtp_diag_code,
+ tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* val(4) */
- diag->val = tvb_get_ntohl(tvb, offset);
+ proto_tree_add_item(xtp_subtree, hf_xtp_diag_val,
+ tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* message(n) */
- msg_len = tvb_reported_length_remaining(tvb, offset);
- diag->msg = tvb_get_string_enc(NULL, tvb, offset, msg_len, ENC_ASCII);
-
- /** display **/
- offset = start;
- /* code(4) */
- proto_tree_add_uint(xtp_subtree, hf_xtp_diag_code,
- tvb, offset, 4, diag->code);
- offset += 4;
- /* val(4) */
- proto_tree_add_uint(xtp_subtree, hf_xtp_diag_val,
- tvb, offset, 4, diag->val);
- offset += 4;
- /* message(4) */
- proto_tree_add_string(xtp_subtree, hf_xtp_diag_msg,
- tvb, offset, msg_len, diag->msg);
- g_free(diag->msg);
+ proto_tree_add_item(xtp_subtree, hf_xtp_diag_msg,
+ tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII|ENC_NA);
return;
}