aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ansi_637.c
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2013-08-19 14:55:41 +0000
committerPascal Quantin <pascal.quantin@gmail.com>2013-08-19 14:55:41 +0000
commitb46f9bebe29e215e0b84242771a92f1bbe6fdb38 (patch)
tree45c8664141827cb3018c2c7b2407fb906e4dad53 /epan/dissectors/packet-ansi_637.c
parent02cae558f997dba1fd17011cc84e317f17d17a4d (diff)
Change some dissectors to use pinfo memory pool instead of malloc if it can trigger an exception between between buffer allocation and tvb_set_free_cb call
svn path=/trunk/; revision=51427
Diffstat (limited to 'epan/dissectors/packet-ansi_637.c')
-rw-r--r--epan/dissectors/packet-ansi_637.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/epan/dissectors/packet-ansi_637.c b/epan/dissectors/packet-ansi_637.c
index 8e102ba511..f541dfc137 100644
--- a/epan/dissectors/packet-ansi_637.c
+++ b/epan/dissectors/packet-ansi_637.c
@@ -33,7 +33,7 @@
#include "config.h"
#include <epan/packet.h>
-#include <epan/emem.h>
+#include <epan/wmem/wmem.h>
#include <epan/strutil.h>
#include "packet-gsm_sms.h"
@@ -572,7 +572,7 @@ tele_param_user_data(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
saved_offset = offset - 1;
i = num_fields * 7;
required_octs = (i / 8) + ((i % 8) ? 1 : 0);
- buf = (gchar*)g_malloc(required_octs);
+ buf = (gchar*)wmem_alloc(g_pinfo->pool, required_octs);
for (i=0; i < required_octs; i++)
{
oct = tvb_get_guint8(tvb, saved_offset);
@@ -581,7 +581,6 @@ tele_param_user_data(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
saved_offset++;
}
tvb_out = tvb_new_child_real_data(tvb, buf, required_octs, required_octs);
- tvb_set_free_cb(tvb_out, g_free);
add_new_data_source(g_pinfo, tvb_out, "Characters");
offset = 0;
bit = 0;
@@ -635,7 +634,7 @@ tele_param_user_data(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
saved_offset = offset - 1;
i = num_fields * 7;
required_octs = (i / 8) + ((i % 8) ? 1 : 0);
- buf = (gchar*)g_malloc(required_octs);
+ buf = (gchar*)wmem_alloc(g_pinfo->pool, required_octs);
for (i=0; i < required_octs; i++)
{
oct = tvb_get_guint8(tvb, saved_offset);
@@ -644,7 +643,6 @@ tele_param_user_data(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
saved_offset++;
}
tvb_out = tvb_new_child_real_data(tvb, buf, required_octs, required_octs);
- tvb_set_free_cb(tvb_out, g_free);
add_new_data_source(g_pinfo, tvb_out, "Characters");
offset = 0;
bit = 0;
@@ -666,7 +664,7 @@ tele_param_user_data(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
{
saved_offset = offset - 1;
required_octs = 2*num_fields;
- buf = (gchar*)g_malloc(required_octs);
+ buf = (gchar*)wmem_alloc(g_pinfo->pool, required_octs);
for (i=0; i < required_octs; i++)
{
oct = tvb_get_guint8(tvb, saved_offset);
@@ -675,7 +673,6 @@ tele_param_user_data(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
saved_offset++;
}
tvb_out = tvb_new_child_real_data(tvb, buf, required_octs, required_octs);
- tvb_set_free_cb(tvb_out, g_free);
add_new_data_source(g_pinfo, tvb_out, "Characters");
offset = 0;
if (g_pinfo->private_data && (GPOINTER_TO_UINT(g_pinfo->private_data) == TRUE)) {
@@ -702,7 +699,7 @@ tele_param_user_data(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
else if (encoding == 0x07)/* Latin/Hebrew */
{
saved_offset = offset - 1;
- buf = (gchar*)g_malloc(num_fields);
+ buf = (gchar*)wmem_alloc(g_pinfo->pool, num_fields);
for (i=0; i < num_fields; i++)
{
oct = tvb_get_guint8(tvb, saved_offset);
@@ -711,7 +708,6 @@ tele_param_user_data(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
saved_offset++;
}
tvb_out = tvb_new_child_real_data(tvb, buf, num_fields, num_fields);
- tvb_set_free_cb(tvb_out, g_free);
add_new_data_source(g_pinfo, tvb_out, "Characters");
offset = 0;
required_octs = len - used;
@@ -739,7 +735,7 @@ tele_param_user_data(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
else if (encoding == 0x08) /* ISO 8859-1 (a/k/a ISO Latin 1) */
{
saved_offset = offset - 1;
- buf = (gchar*)g_malloc(num_fields);
+ buf = (gchar*)wmem_alloc(g_pinfo->pool, num_fields);
for (i=0; i < num_fields; i++)
{
oct = tvb_get_guint8(tvb, saved_offset);
@@ -748,7 +744,6 @@ tele_param_user_data(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
saved_offset++;
}
tvb_out = tvb_new_child_real_data(tvb, buf, num_fields, num_fields);
- tvb_set_free_cb(tvb_out, g_free);
add_new_data_source(g_pinfo, tvb_out, "Characters");
offset = 0;
required_octs = len - used;
@@ -790,7 +785,7 @@ tele_param_user_data(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
saved_offset = offset - 1;
i = num_fields * 7;
required_octs = (i / 8) + ((i % 8) ? 1 : 0);
- buf = (gchar*)g_malloc(required_octs);
+ buf = (gchar*)wmem_alloc(g_pinfo->pool, required_octs);
for (i=0; i < required_octs; i++)
{
oct = tvb_get_guint8(tvb, saved_offset);
@@ -799,7 +794,6 @@ tele_param_user_data(tvbuff_t *tvb, proto_tree *tree, guint len, guint32 offset)
saved_offset++;
}
tvb_out = tvb_new_child_real_data(tvb, buf, required_octs, required_octs);
- tvb_set_free_cb(tvb_out, g_free);
add_new_data_source(g_pinfo, tvb_out, "Characters");
offset = 0;
bit = 0;
@@ -2122,7 +2116,7 @@ dissect_ansi_637_trans_param(tvbuff_t *tvb, proto_tree *tree, guint32 *offset)
{
gchar *ansi_637_add_string;
- ansi_637_add_string = (gchar *)ep_alloc(1024);
+ ansi_637_add_string = (gchar *)wmem_alloc(wmem_packet_scope(), 1024);
ansi_637_add_string[0] = '\0';
(*param_fcn)(tvb, subtree, len, curr_offset, ansi_637_add_string, 1024);