Blame SOURCES/0029-resource-Fix-ovirt_resource_rest_call_sync-crash-on-.patch

1bd27f
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
3e596a
From: Christophe Fergeau <cfergeau@redhat.com>
3e596a
Date: Tue, 25 Jul 2017 17:36:05 +0200
3e596a
Subject: [PATCH] resource: Fix ovirt_resource_rest_call_sync() crash on 404
3e596a
3e596a
When the REST call fails, we do not always get an XML answer from oVirt
3e596a
describing the failure in more details. In particular, this is the case
3e596a
when we hit a 404. In such situations, we'd be crashing because we'd
3e596a
attempt to dereference a NULL pointer.
3e596a
---
3e596a
 govirt/ovirt-resource.c | 9 +++++----
3e596a
 1 file changed, 5 insertions(+), 4 deletions(-)
3e596a
3e596a
diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
3e596a
index 0c750ac..0f4a129 100644
3e596a
--- a/govirt/ovirt-resource.c
3e596a
+++ b/govirt/ovirt-resource.c
3e596a
@@ -485,16 +485,17 @@ G_GNUC_INTERNAL RestXmlNode *ovirt_resource_rest_call_sync(OvirtRestCall *call,
3e596a
         GError *local_error = NULL;
3e596a
 
3e596a
         root = ovirt_rest_xml_node_from_call(REST_PROXY_CALL(call));
3e596a
-        ovirt_utils_gerror_from_xml_fault(root, &local_error);
3e596a
+        if (root != NULL) {
3e596a
+            ovirt_utils_gerror_from_xml_fault(root, &local_error);
3e596a
+            rest_xml_node_unref(root);
3e596a
+        }
3e596a
         if (local_error != NULL) {
3e596a
             g_clear_error(error);
3e596a
             g_warning("Error while updating resource");
3e596a
             g_warning("message: %s", local_error->message);
3e596a
             g_propagate_error(error, local_error);
3e596a
         }
3e596a
-        if (root != NULL) {
3e596a
-            rest_xml_node_unref(root);
3e596a
-        }
3e596a
+        g_warn_if_fail(error == NULL || *error != NULL);
3e596a
 
3e596a
         return NULL;
3e596a
     }