[libgovirt] resource: Fix ovirt_resource_rest_call_sync() crash on 404
- From: Eduardo de Barros Lima <eblima src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgovirt] resource: Fix ovirt_resource_rest_call_sync() crash on 404
- Date: Wed, 9 Aug 2017 20:03:14 +0000 (UTC)
commit 4ea5990d49abe84d53119b527558f27364d91b54
Author: Christophe Fergeau <cfergeau redhat com>
Date: Tue Jul 25 17:36:05 2017 +0200
resource: Fix ovirt_resource_rest_call_sync() crash on 404
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.
govirt/ovirt-resource.c | 9 +++++----
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]