aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-20 08:42:51 +0000
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-20 08:42:51 +0000
commita569e8d5b812357027f47b3faba94ef41d3a84fa (patch)
tree72e5b6381733ecc29e4d1dfc8368e5dfb9c4fca9
parent9441e9b34471603f65c223c5c2a19c1c3adfd5e9 (diff)
Use tvb_get_ephemeral_string() to avoid memleak (should have been part of r29994.
svn path=/trunk/; revision=30003
-rw-r--r--epan/dissectors/packet-rtps.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/epan/dissectors/packet-rtps.c b/epan/dissectors/packet-rtps.c
index 590972d96b..140cfa8238 100644
--- a/epan/dissectors/packet-rtps.c
+++ b/epan/dissectors/packet-rtps.c
@@ -1546,7 +1546,7 @@ static gint rtps_util_add_string(proto_tree *tree, /* Can be NULL */
guint32 size = NEXT_guint32(tvb, offset, little_endian);
if (size > 0) {
- retVal = tvb_get_string(tvb, offset+4, size);
+ retVal = tvb_get_ephemeral_string(tvb, offset+4, size);
}
if (tree != NULL) {
@@ -1575,7 +1575,6 @@ static gint rtps_util_add_string(proto_tree *tree, /* Can be NULL */
g_snprintf(buffer, (gulong) buffer_size, "%s", retVal);
}
}
- g_free(retVal);
/* NDDS align strings at 4-bytes word. So:
* string_length: 4 -> buffer_length = 4;
@@ -2139,7 +2138,7 @@ static gint rtps_util_add_typecode(proto_tree *tree,
/* Get structure name length */
struct_name_len = NEXT_guint32(tvb, offset, little_endian);
offset += 4;
- struct_name = tvb_get_string(tvb, offset, struct_name_len);
+ struct_name = tvb_get_ephemeral_string(tvb, offset, struct_name_len);
offset += struct_name_len;
/* - - - - - - - Default index - - - - - - - */
@@ -2161,7 +2160,7 @@ static gint rtps_util_add_typecode(proto_tree *tree,
/* Enums has also a name that we should print */
LONG_ALIGN(offset);
discriminator_enum_name_length = NEXT_guint32(tvb, offset, little_endian);
- discriminator_enum_name = tvb_get_string(tvb, offset+4, discriminator_enum_name_length);
+ discriminator_enum_name = tvb_get_ephemeral_string(tvb, offset+4, discriminator_enum_name_length);
}
offset = disc_offset_begin + disc_size;
/*
@@ -2199,11 +2198,9 @@ static gint rtps_util_add_typecode(proto_tree *tree,
if (seq_max_len != -1) {
/* We're dissecting a sequence of struct, bypass the seq definition */
g_snprintf(type_name, 40, "%s", struct_name);
- g_free(struct_name);
break;
}
- g_free(struct_name);
/* - - - - - - - Number of members - - - - - - - */
LONG_ALIGN(offset);
num_members = NEXT_guint32(tvb, offset, little_endian);