summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2017-07-25 17:36:05 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2017-07-25 17:37:22 +0200
commitb1ac5f287127af3e381e6bef8ce280aa17c6e2a5 (patch)
tree27741adaccd2ff0404870aeebd6a1b6052b3fabe
parent5ca6d2dc2807887de49d5ce556f71c32840549f0 (diff)
resource: Fix ovirt_resource_rest_call_sync() crash on 404datacenter
When the REST call fails, we do not always get an XML answer from oVirt describing the failure in more details. In particular, this is the case when we hit a 404. In such situations, we'd be crashing because we'd attempt to dereference a NULL pointer.
-rw-r--r--govirt/ovirt-resource.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
index 0c750ac..0f4a129 100644
--- a/govirt/ovirt-resource.c
+++ b/govirt/ovirt-resource.c
@@ -485,16 +485,17 @@ G_GNUC_INTERNAL RestXmlNode *ovirt_resource_rest_call_sync(OvirtRestCall *call,
GError *local_error = NULL;
root = ovirt_rest_xml_node_from_call(REST_PROXY_CALL(call));
- ovirt_utils_gerror_from_xml_fault(root, &local_error);
+ if (root != NULL) {
+ ovirt_utils_gerror_from_xml_fault(root, &local_error);
+ rest_xml_node_unref(root);
+ }
if (local_error != NULL) {
g_clear_error(error);
g_warning("Error while updating resource");
g_warning("message: %s", local_error->message);
g_propagate_error(error, local_error);
}
- if (root != NULL) {
- rest_xml_node_unref(root);
- }
+ g_warn_if_fail(error == NULL || *error != NULL);
return NULL;
}