From 02e303ea3ac4a1bef70ad1e79ae402e6ad02ebd3 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Fri, 5 Aug 2016 10:33:35 -0500
Subject: [PATCH] Low: libcib,libfencing,libtransition: handle memory
allocation errors without CRM_CHECK()
makes coverity happy
---
lib/cib/cib_attrs.c | 5 ++++-
lib/fencing/st_client.c | 6 +++++-
lib/transition/unpack.c | 6 +++++-
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/lib/cib/cib_attrs.c b/lib/cib/cib_attrs.c
index d929fa2..1e1a369 100644
--- a/lib/cib/cib_attrs.c
+++ b/lib/cib/cib_attrs.c
@@ -93,7 +93,10 @@ find_nvpair_attr_delegate(cib_t * the_cib, const char *attr, const char *section
}
xpath_string = calloc(1, xpath_max);
- CRM_CHECK(xpath_string != NULL, return -ENOMEM);
+ if (xpath_string == NULL) {
+ crm_perror(LOG_CRIT, "Could not create xpath");
+ return -ENOMEM;
+ }
attr_snprintf(xpath_string, offset, xpath_max, "%.128s", get_object_path(section));
diff --git a/lib/fencing/st_client.c b/lib/fencing/st_client.c
index 6d4dce1..e1eda35 100644
--- a/lib/fencing/st_client.c
+++ b/lib/fencing/st_client.c
@@ -353,7 +353,11 @@ create_level_registration_xml(const char *node, const char *pattern,
crm_trace("Adding %s (%dc) at offset %d", device_list->value, adding, len);
list = realloc_safe(list, len + adding + 1); /* +1 EOS */
- CRM_CHECK(list != NULL, free_xml(data); return NULL);
+ if (list == NULL) {
+ crm_perror(LOG_CRIT, "Could not create device list");
+ free_xml(data);
+ return NULL;
+ }
sprintf(list + len, "%s%s", len?",":"", device_list->value);
len += adding;
}
diff --git a/lib/transition/unpack.c b/lib/transition/unpack.c
index 7a8c656..bdb01d1 100644
--- a/lib/transition/unpack.c
+++ b/lib/transition/unpack.c
@@ -41,7 +41,11 @@ unpack_action(synapse_t * parent, xmlNode * xml_action)
}
action = calloc(1, sizeof(crm_action_t));
- CRM_CHECK(action != NULL, return NULL);
+ if (action == NULL) {
+ crm_perror(LOG_CRIT, "Cannot unpack action");
+ crm_log_xml_trace(xml_action, "Lost action");
+ return NULL;
+ }
action->id = crm_parse_int(value, NULL);
action->type = action_type_rsc;
--
1.8.3.1