summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 014985d)
raw | patch | inline | side by side (parent: 014985d)
author | Ben Knight <bkk@nerdboy.net.au> | |
Tue, 1 Dec 2009 08:03:27 +0000 (09:03 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 1 Dec 2009 08:03:27 +0000 (09:03 +0100) |
We've run into a memory leak in collectd, triggered by usage of 'listval'
via the unixsock plugin.
When making a 'listval' call, utils_cmd_listval.c:handle_listval() calls
utils_cache.c:uc_get_names() to retrieve a list of active value names from the
internal cache. uc_get_names() uses realloc() to allocate memory in which to
store the list, and returns pointers.
handle_listval() does not perform a free() on the returned memory. Each time
listval is called, some memory is leaked. handle_getval() does not suffer from
the same problem - a free() is called in that case.
via the unixsock plugin.
When making a 'listval' call, utils_cmd_listval.c:handle_listval() calls
utils_cache.c:uc_get_names() to retrieve a list of active value names from the
internal cache. uc_get_names() uses realloc() to allocate memory in which to
store the list, and returns pointers.
handle_listval() does not perform a free() on the returned memory. Each time
listval is called, some memory is leaked. handle_getval() does not suffer from
the same problem - a free() is called in that case.
src/utils_cmd_listval.c | patch | blob | history |
index bca83a9996a220870fd9651555e1d56bad090397..072593f92939366bfc433b6d22bf236129fdcc6c 100644 (file)
--- a/src/utils_cmd_listval.c
+++ b/src/utils_cmd_listval.c
print_to_socket (fh, "%i Value%s found\n",
(int) number, (number == 1) ? "" : "s");
for (i = 0; i < number; i++)
+ {
print_to_socket (fh, "%u %s\n", (unsigned int) times[i], names[i]);
+ sfree(names[i]);
+ }
+ sfree(names);
+ sfree(times);
+
return (0);
} /* int handle_listval */