From: Ruben Kerkhof Date: Thu, 3 Dec 2015 14:14:37 +0000 (+0100) Subject: Merge pull request #1391 from rubenk/openvpn X-Git-Tag: collectd-5.6.0~530 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=aa958d2ad30d29553e489bc727254a8eedb4ea17;hp=4557bc77cfab048f96ff50957db08936d80b0ebf;p=collectd.git Merge pull request #1391 from rubenk/openvpn openvpn plugin: Check return value of malloc(). --- diff --git a/src/openvpn.c b/src/openvpn.c index 663a82d8..93c8f1b5 100644 --- a/src/openvpn.c +++ b/src/openvpn.c @@ -697,6 +697,14 @@ 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)); + if (temp == NULL) + { + char errbuf[1024]; + ERROR ("openvpn plugin: malloc failed: %s", + sstrerror (errno, errbuf, sizeof (errbuf))); + sfree (status_file); + return (1); + } temp->file = status_file; temp->version = status_version; temp->name = status_name; @@ -705,7 +713,7 @@ static int openvpn_config (const char *key, const char *value) if (vpn_list == NULL) { char errbuf[1024]; - ERROR ("openvpn plugin: malloc failed: %s", + ERROR ("openvpn plugin: realloc failed: %s", sstrerror (errno, errbuf, sizeof (errbuf))); sfree (temp->file);