diff options
| author | David Sommerseth <davids@redhat.com> | 2011-04-11 14:30:36 +0200 |
|---|---|---|
| committer | David Sommerseth <davids@redhat.com> | 2011-04-11 14:30:36 +0200 |
| commit | abc7f912f66d41dd734a10900429d4cad9377da5 (patch) | |
| tree | 91e26638c7d7a84fe750d037ca0231a34463ff30 /python-ethtool/etherinfo.c | |
| parent | 710766dc72260149bd78fd6168fbaf6838fc3d4f (diff) | |
| download | python-ethtool-abc7f912f66d41dd734a10900429d4cad9377da5.tar.gz python-ethtool-abc7f912f66d41dd734a10900429d4cad9377da5.tar.xz python-ethtool-abc7f912f66d41dd734a10900429d4cad9377da5.zip | |
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 <davids@redhat.com>
Diffstat (limited to 'python-ethtool/etherinfo.c')
| -rw-r--r-- | python-ethtool/etherinfo.c | 6 |
1 files changed, 2 insertions, 4 deletions
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; } |
