From: Marco Chiappero Date: Fri, 25 Sep 2009 07:20:56 +0000 (+0200) Subject: openvpn plugin: Add forgotten frees. X-Git-Tag: collectd-4.9.0~37^2~12 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4fa49f23569090363a8affcefe18b863cc486b29;p=collectd.git openvpn plugin: Add forgotten frees. Florian Forster ha scritto: > Hi Marco, Hi Florian, > I'm too tired to have a look at this now, I hope to have some time in > the next few days. I'll come back to you asap. That's fine :) But sorry, I forgot to recheck a small part of the code after adding and moving some stuff around, please apply this patch too. Regards, Marco --- diff --git a/src/openvpn.c b/src/openvpn.c index bf8511c3..e65a00a6 100644 --- a/src/openvpn.c +++ b/src/openvpn.c @@ -492,12 +492,14 @@ static int openvpn_config (const char *key, const char *value) { WARNING ("status filename \"%s\" already used, \ please choose a different one.", status_name); + + sfree (status_file); return (1); } } } - /* create a new vpn element since file and version are ok */ + /* create a new vpn element since file, version and name are ok */ temp = (vpn_status_t *) malloc (sizeof (vpn_status_t)); temp->file = status_file; temp->version = status_version; @@ -506,10 +508,13 @@ static int openvpn_config (const char *key, const char *value) vpn_list = (vpn_status_t **) realloc (vpn_list, (vpn_num + 1) * sizeof (vpn_status_t *)); if (vpn_list == NULL) { - char errbuf[1024]; - ERROR ("openvpn plugin: malloc failed: %s", - sstrerror (errno, errbuf, sizeof (errbuf))); - return (1); + char errbuf[1024]; + ERROR ("openvpn plugin: malloc failed: %s", + sstrerror (errno, errbuf, sizeof (errbuf))); + + sfree (temp->file); + sfree (temp); + return (1); } vpn_list[vpn_num] = temp;