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

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