From: Ruben Kerkhof Date: Sat, 23 Apr 2016 09:35:26 +0000 (+0200) Subject: openvpn plugin: plug leak on realloc failure X-Git-Tag: collectd-5.6.0~329^2~18 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c5238e787a51ec3c7e2b2bd1d7a79524b7bb65df;p=collectd.git openvpn plugin: plug leak on realloc failure [src/openvpn.c:715]: (error) Common realloc mistake: 'vpn_list' nulled but not freed upon failure --- diff --git a/src/openvpn.c b/src/openvpn.c index 9490ac8b..85760e99 100644 --- a/src/openvpn.c +++ b/src/openvpn.c @@ -712,17 +712,19 @@ static int openvpn_config (const char *key, const char *value) temp->version = status_version; temp->name = status_name; - vpn_list = realloc (vpn_list, (vpn_num + 1) * sizeof (*vpn_list)); - if (vpn_list == NULL) + vpn_status_t **tmp_list = realloc (vpn_list, (vpn_num + 1) * sizeof (*vpn_list)); + if (tmp_list == NULL) { char errbuf[1024]; ERROR ("openvpn plugin: realloc failed: %s", sstrerror (errno, errbuf, sizeof (errbuf))); + sfree (vpn_list); sfree (temp->file); sfree (temp); return (1); } + vpn_list = tmp_list; vpn_list[vpn_num] = temp; vpn_num++;