From abc7f912f66d41dd734a10900429d4cad9377da5 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Mon, 11 Apr 2011 14:30:36 +0200 Subject: Fixed several memory leaks Several places python-ethtool leaked memory, mostly due to missing Py_DECREF() calls on objects being put in to python lists (via PyList_Append() calls). This revealed an issue in addition where the IPv6 addresses pointers in some cases could freed more times. This is fixed as well. Signed-off-by: David Sommerseth --- python-ethtool/etherinfo.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'python-ethtool/etherinfo.c') diff --git a/python-ethtool/etherinfo.c b/python-ethtool/etherinfo.c index 3d2072b..5539cf7 100644 --- a/python-ethtool/etherinfo.c +++ b/python-ethtool/etherinfo.c @@ -59,16 +59,14 @@ void free_ipv6addresses(struct ipv6address *ptr) { struct ipv6address *ipv6ptr = ptr; - if( !ptr ) { - return; - } - while( ipv6ptr ) { struct ipv6address *tmp = ipv6ptr->next; if( ipv6ptr->address ) { free(ipv6ptr->address); + ipv6ptr->address = NULL; } + memset(ipv6ptr, 0, sizeof(struct ipv6address)); free(ipv6ptr); ipv6ptr = tmp; } -- cgit