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

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