From 6ce771ab08db6f57d91836356bd3a1e1439b10e8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bruno=20Pr=C3=A9mont?= Date: Sat, 17 Jan 2009 11:40:53 +0100 Subject: [PATCH 1/1] ascent plugin: Fix a memory leak. According to libxml2 API doc, the string returned by xmlNodeListGetString() must be freed by the user with xmlFree() The attached patch adds the missing calls to xmlFree() for the ascent plugin. --- src/ascent.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ascent.c b/src/ascent.c index 8c0bbec6..e0b6ba2d 100644 --- a/src/ascent.c +++ b/src/ascent.c @@ -271,10 +271,12 @@ static int ascent_xml_submit_gauge (xmlDoc *doc, xmlNode *node, /* {{{ */ value = strtod (str_ptr, &end_ptr); if (str_ptr == end_ptr) { + xmlFree(str_ptr); ERROR ("ascent plugin: ascent_xml_submit_gauge: strtod failed."); return (-1); } } + xmlFree(str_ptr); return (ascent_submit_gauge (plugin_instance, type, type_instance, value)); } /* }}} int ascent_xml_submit_gauge */ @@ -300,10 +302,12 @@ static int ascent_xml_read_int (xmlDoc *doc, xmlNode *node, /* {{{ */ value = strtol (str_ptr, &end_ptr, 0); if (str_ptr == end_ptr) { + xmlFree(str_ptr); ERROR ("ascent plugin: ascent_xml_read_int: strtol failed."); return (-1); } } + xmlFree(str_ptr); *ret_value = value; return (0); -- 2.11.0