[collectd] [PATCH] perl plugin: Fixed a memory leak in pplugin_register_data_set().

Sebastian Harl sh at tokkee.org
Mon Nov 26 12:17:26 CET 2007


The data set definition is copied by plugin_register_data_set() (in plugin.c)
and thus should be freed after it has been passed on to the plugin module.

Signed-off-by: Sebastian Harl <sh at tokkee.org>
---
 src/perl.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/perl.c b/src/perl.c
index c0e99f5..dc548b2 100644
--- a/src/perl.c
+++ b/src/perl.c
@@ -388,6 +388,7 @@ static char *get_module_name (char *buf, size_t buf_len, const char *module) {
 static int pplugin_register_data_set (pTHX_ char *name, AV *dataset)
 {
 	int len = -1;
+	int ret = 0;
 	int i   = 0;
 
 	data_source_t *ds  = NULL;
@@ -428,7 +429,12 @@ static int pplugin_register_data_set (pTHX_ char *name, AV *dataset)
 
 	set->ds_num = len + 1;
 	set->ds = ds;
-	return plugin_register_data_set (set);
+
+	ret = plugin_register_data_set (set);
+
+	free (ds);
+	free (set);
+	return ret;
 } /* static int pplugin_register_data_set (char *, SV *) */
 
 /*
-- 
1.5.3.6.736.gb7f30

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20071126/041eab24/attachment.pgp 


More information about the collectd mailing list