X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fopenvpn.c;h=85760e996d27b8cd6a6cce3abb531631ad908ab1;hb=db35efb33e81d0a013e09a8a6ffa362ad5962f7c;hp=8bccce3883a88664598416dbc5a7e0c676c9a051;hpb=5c2993e4121feae745551be182221b31bc23ff97;p=collectd.git diff --git a/src/openvpn.c b/src/openvpn.c index 8bccce38..85760e99 100644 --- a/src/openvpn.c +++ b/src/openvpn.c @@ -699,7 +699,7 @@ static int openvpn_config (const char *key, const char *value) } /* create a new vpn element since file, version and name are ok */ - temp = (vpn_status_t *) malloc (sizeof (vpn_status_t)); + temp = malloc (sizeof (*temp)); if (temp == NULL) { char errbuf[1024]; @@ -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++;