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

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

 



This issues is more widespread than that, it would be better to fix it
everywhere in one go (maybe through a gvir_config_object_check_type() or
something like this?)

Christophe

On Tue, Mar 22, 2016 at 11:04:53AM +0100, Fabiano Fidêncio wrote:
> Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
> ---
>  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
> 
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: signature.asc
Description: PGP signature

--
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]