summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 40f37f0)
raw | patch | inline | side by side (parent: 40f37f0)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 24 Sep 2009 07:42:12 +0000 (09:42 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 24 Sep 2009 07:42:12 +0000 (09:42 +0200) |
Check return value of "malloc".
src/netapp.c | patch | blob | history |
diff --git a/src/netapp.c b/src/netapp.c
index 19b27d1150d897d6fd3bf856a3dbc9cee38434b1..9c7961a872319bfbaa017dd48c8e7c0e98d529b7 100644 (file)
--- a/src/netapp.c
+++ b/src/netapp.c
@@ -1082,22 +1082,32 @@ static void build_perf_wafl_config(host_config_t *temp, oconfig_item_t *ci) {
}
}
-static void build_perf_sys_config(host_config_t *temp, oconfig_item_t *ci, const service_config_t *default_service) {
+static int build_perf_sys_config (host_config_t *host, /* {{{ */
+ oconfig_item_t *ci, const service_config_t *default_service)
+{
int i;
service_config_t *service;
perf_system_data_t *perf_system;
service = malloc(sizeof(*service));
+ if (service == NULL)
+ return (-1);
+ memset (service, 0, sizeof (*service));
*service = *default_service;
service->handler = collect_perf_system_data;
- perf_system = service->data = malloc(sizeof(*perf_system));
+
+ perf_system = malloc(sizeof(*perf_system));
+ if (perf_system == NULL) {
+ sfree (service);
+ return (-1);
+ }
+ memset (perf_system, 0, sizeof (*perf_system));
perf_system->flags = PERF_SYSTEM_ALL;
- service->next = temp->services;
- temp->services = service;
+ service->data = perf_system;
+
for (i = 0; i < ci->children_num; ++i) {
oconfig_item_t *item = ci->children + i;
- /* if (!item || !item->key || !*item->key) continue; */
if (!strcasecmp(item->key, "Multiplier")) {
if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_NUMBER || item->values[0].value.number != (int) item->values[0].value.number || item->values[0].value.number < 1) {
WARNING("netapp plugin: \"Multiplier\" of host %s service GetSystemPerfData needs exactly one positive integer argument.", ci->values[0].value.string);
@@ -1117,7 +1127,12 @@ static void build_perf_sys_config(host_config_t *temp, oconfig_item_t *ci, const
"`GetSystemPerfData' blocks.", item->key);
}
}
-}
+
+ service->next = host->services;
+ host->services = service;
+
+ return (0);
+} /* }}} int build_perf_sys_config */
static host_config_t *build_host_config(const oconfig_item_t *ci, const host_config_t *default_host, const service_config_t *def_def_service) {
int i;