From c5238e787a51ec3c7e2b2bd1d7a79524b7bb65df Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Sat, 23 Apr 2016 11:35:26 +0200 Subject: [PATCH] openvpn plugin: plug leak on realloc failure [src/openvpn.c:715]: (error) Common realloc mistake: 'vpn_list' nulled but not freed upon failure --- src/openvpn.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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++; -- 2.11.0