aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-iax2.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-06-19 11:58:21 -0700
committerGuy Harris <guy@alum.mit.edu>2014-06-19 18:58:49 +0000
commit46ecf18fbdb6f02b1748ca72bd5e6ecf0e6c0886 (patch)
tree8825c184d1932efca50cfe4aabd4e7798cdefd1a /epan/dissectors/packet-iax2.c
parent83762f9f9be517ef155f5b0649962809ba593550 (diff)
Use address_to_str(NULL, ...) for strings allocated outside dissectors.
ep_address_to_str() doesn't crash if called outside packet scope, but it's still not correct to use outside packet scope. Use address_to_str(NULL, ...) to allocate those strings, and then explicitly free them when we're done; exceptions don't get thrown between the allocate and free, so there's no risk of a leak. Change-Id: Iea2af93b0757e648d399e2ba64249224eb7e9e3c Reviewed-on: https://code.wireshark.org/review/2438 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/dissectors/packet-iax2.c')
-rw-r--r--epan/dissectors/packet-iax2.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/epan/dissectors/packet-iax2.c b/epan/dissectors/packet-iax2.c
index dd60ab58b3..1a14bfb50b 100644
--- a/epan/dissectors/packet-iax2.c
+++ b/epan/dissectors/packet-iax2.c
@@ -597,7 +597,9 @@ static guint circuitcount = 0;
static gchar *key_to_str( const iax_circuit_key *key )
{
static int i = 0;
- static gchar *strp, str[3][80];
+ static gchar str[3][80];
+ gchar *strp;
+ gchar *addrstr;
i++;
if (i >= 3) {
@@ -608,11 +610,12 @@ static gchar *key_to_str( const iax_circuit_key *key )
/* why doesn't ep_address_to_str take a const pointer?
cast the warnings into oblivion. */
- /* XXX - is this a case for wmem_packet_scope()? */
+ addrstr = address_to_str(NULL, (address *)&key->addr)
g_snprintf(strp, 80, "{%s:%i,%i}",
- ep_address_to_str((address *)&key->addr),
+ addrstr,
key->port,
key->callno);
+ wmem_free(NULL, addrstr);
return strp;
}
#endif
@@ -928,12 +931,19 @@ static iax_call_data *iax_lookup_call( packet_info *pinfo,
gboolean reversed = FALSE;
iax_call_data *iax_call = NULL;
guint src_circuit_id;
+#ifdef DEBUG_HASHING
+ gchar *srcstr, *dststr;
+#endif
#ifdef DEBUG_HASHING
+ srcstr = address_to_str(NULL, &pinfo->src);
+ dststr = address_to_str(NULL, &pinfo->dst);
g_debug("++ iax_lookup_circuit_details: Looking up circuit for frame %u, "
"from {%s:%u:%u} to {%s:%u:%u}", pinfo->fd->num,
- ep_address_to_str(&pinfo->src), pinfo->srcport, scallno,
- ep_address_to_str(&pinfo->dst), pinfo->destport, dcallno);
+ srcstr, pinfo->srcport, scallno,
+ dststr, pinfo->destport, dcallno);
+ wmem_free(NULL, srcstr);
+ wmem_free(NULL, dststr);
#endif