diff options
author | Evan Huus <eapache@gmail.com> | 2015-06-21 14:02:43 +0000 |
---|---|---|
committer | Pascal Quantin <pascal.quantin@gmail.com> | 2015-06-21 18:40:01 +0000 |
commit | a2e2c1f99783b5ad1048e9bba5b7a2834680b5fd (patch) | |
tree | a5cd57cd5cf6790e2f43b77bf1a904c3dbeda8ea /epan/addr_resolv.c | |
parent | 27fc2b79851b179a833f89923d3c13d8522ce03d (diff) |
Fix memory leak printing eui64s
The scope that is passed in should only be used for the return value - other
temporary buffers we must alloc/free ourselves, since if the scope is NULL they
will not be managed automatically.
Bug: 11293
Change-Id: I27be856f1c5cdf47f78e766192a29523664a543e
Reviewed-on: https://code.wireshark.org/review/9007
Reviewed-by: Evan Huus <eapache@gmail.com>
Petri-Dish: Evan Huus <eapache@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'epan/addr_resolv.c')
-rw-r--r-- | epan/addr_resolv.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c index c580311b1a..7fcfbcc057 100644 --- a/epan/addr_resolv.c +++ b/epan/addr_resolv.c @@ -3221,18 +3221,22 @@ char* get_hash_manuf_resolved_name(hashmanuf_t* manuf) const gchar * eui64_to_display(wmem_allocator_t *allocator, const guint64 addr_eui64) { - guint8 *addr = (guint8 *)wmem_alloc(allocator, 8); + guint8 *addr = (guint8 *)wmem_alloc(NULL, 8); hashmanuf_t *manuf_value; + const gchar *ret; /* Copy and convert the address to network byte order. */ *(guint64 *)(void *)(addr) = pntoh64(&(addr_eui64)); manuf_value = manuf_name_lookup(addr); if (!gbl_resolv_flags.mac_name || (manuf_value->status == HASHETHER_STATUS_UNRESOLVED)) { - return wmem_strdup_printf(allocator, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7]); + ret = wmem_strdup_printf(allocator, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7]); + } else { + ret = wmem_strdup_printf(allocator, "%s_%02x:%02x:%02x:%02x:%02x", manuf_value->resolved_name, addr[3], addr[4], addr[5], addr[6], addr[7]); } - return wmem_strdup_printf(allocator, "%s_%02x:%02x:%02x:%02x:%02x", manuf_value->resolved_name, addr[3], addr[4], addr[5], addr[6], addr[7]); + wmem_free(NULL, addr); + return ret; } /* eui64_to_display */ #ifdef HAVE_C_ARES |