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

[libvirt] [libvirt-glib/libvirt-gconfig 17/17] gconfig, graphics: Avoid crash when gvir_config_object_new_from_xml() returns NULL



Signed-off-by: Fabiano Fidêncio <fidencio redhat com>
---
 libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c | 3 +++
 libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c     | 3 +++
 libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c     | 3 +++
 libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c   | 3 +++
 libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c     | 3 +++
 5 files changed, 15 insertions(+)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c
index 7d23b77..092020d 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.c
@@ -66,6 +66,9 @@ gvir_config_domain_graphics_desktop_new_from_xml(const gchar *xml,
 
     object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_DESKTOP,
                                              "graphics", NULL, xml, error);
+    if (object == NULL)
+        return NULL;
+
     if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "desktop") != 0) {
         g_object_unref(G_OBJECT(object));
         return NULL;
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c
index 4671b13..024c7e9 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.c
@@ -66,6 +66,9 @@ gvir_config_domain_graphics_rdp_new_from_xml(const gchar *xml,
 
     object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_RDP,
                                              "graphics", NULL, xml, error);
+    if (object == NULL)
+        return NULL;
+
     if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "rdp") != 0) {
         g_object_unref(G_OBJECT(object));
         return NULL;
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c
index 55d0012..3bb6c98 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c
@@ -66,6 +66,9 @@ gvir_config_domain_graphics_sdl_new_from_xml(const gchar *xml,
 
     object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_SDL,
                                              "graphics", NULL, xml, error);
+    if (object == NULL)
+        return NULL;
+
     if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "sdl") != 0) {
         g_object_unref(G_OBJECT(object));
         return NULL;
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
index 74466d0..9951ab6 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
@@ -67,6 +67,9 @@ gvir_config_domain_graphics_spice_new_from_xml(const gchar *xml,
 
     object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_SPICE,
                                              "graphics", NULL, xml, error);
+    if (object == NULL)
+        return NULL;
+
     if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "spice") != 0) {
         g_object_unref(G_OBJECT(object));
         return NULL;
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
index 4bd7b25..1cccb31 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
@@ -66,6 +66,9 @@ gvir_config_domain_graphics_vnc_new_from_xml(const gchar *xml,
 
     object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_VNC,
                                              "graphics", NULL, xml, error);
+    if (object == NULL)
+        return NULL;
+
     if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "vnc") != 0) {
         g_object_unref(G_OBJECT(object));
         return NULL;
-- 
2.5.0


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