X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fopenvpn.c;h=85760e996d27b8cd6a6cce3abb531631ad908ab1;hb=b81104a423234c04f0eb4ace0ec5e93a363c917a;hp=ec76a7aa66b5f69f749c6add9adfd15adf8187be;hpb=5841d1fb13436af787c748a965084cb06e66d326;p=collectd.git diff --git a/src/openvpn.c b/src/openvpn.c index ec76a7aa..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 = (vpn_status_t **) realloc (vpn_list, (vpn_num + 1) * sizeof (vpn_status_t *)); - 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++;