[libvirt-glib 02/23] gvir_config_object_parse: don't parse empty documents

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Report an error when trying to parse the current XML document
associated with the GVirConfig object when no document has been
set.
---
 libvirt-gconfig/libvirt-gconfig-object.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index 4a58323..6f80346 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -187,6 +187,14 @@ gvir_config_object_parse(GVirConfigObject *config,
     if (priv->docHandle)
         return;
 
+    if (!priv->doc) {
+        *err = g_error_new(GVIR_CONFIG_OBJECT_ERROR,
+                           0,
+                           "%s",
+                           "No XML document to parse");
+        return;
+    }
+
     priv->docHandle = xmlParseMemory(priv->doc, strlen(priv->doc));
     if (!priv->docHandle) {
         *err = gvir_xml_error_new(GVIR_CONFIG_OBJECT_ERROR,
-- 
1.7.6.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]