From 46ecf18fbdb6f02b1748ca72bd5e6ecf0e6c0886 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 19 Jun 2014 11:58:21 -0700 Subject: 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 --- epan/dissectors/packet-tacacs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'epan/dissectors/packet-tacacs.c') diff --git a/epan/dissectors/packet-tacacs.c b/epan/dissectors/packet-tacacs.c index e663c72997..7d133a8a60 100644 --- a/epan/dissectors/packet-tacacs.c +++ b/epan/dissectors/packet-tacacs.c @@ -748,13 +748,17 @@ static void tacplus_print_key_entry( gpointer data, gpointer user_data ) { tacplus_key_entry *tacplus_data=(tacplus_key_entry *)data; + gchar *s_str, *c_str; + + s_str = address_to_str( NULL, tacplus_data->s ); + c_str = address_to_str( NULL, tacplus_data->c ); if( user_data ) { - printf("%s:%s=%s\n", ep_address_to_str( tacplus_data->s ), - ep_address_to_str( tacplus_data->c ), tacplus_data->k ); + printf("%s:%s=%s\n", s_str, c_str, tacplus_data->k ); } else { - printf("%s:%s\n", ep_address_to_str( tacplus_data->s ), - ep_address_to_str( tacplus_data->c ) ); + printf("%s:%s\n", s_str, c_str ); } + wmem_free(NULL, s_str); + wmem_free(NULL, c_str); } #endif static int -- cgit v1.2.3