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

Re: [libvirt] [libvirt-glib] Fix *_new_from_xml



On Wed, Jul 18, 2012 at 03:16:03PM +0200, Christophe Fergeau wrote:
> For objects with a subtype 'type' attribute, when the _new_from_xml
> function was called, the 'type' attribute was forcefully set to the
> right value rather than checking that the passed-in value matches
> the type of the subclass we are trying to instantiate. This commit
> changes this, and returns NULL when the value of the 'type' attribute
> of the passed-in XML document does not match the expected type.
> ---
>  libvirt-gconfig/libvirt-gconfig-domain-address-pci.c             |    2 +-
>  libvirt-gconfig/libvirt-gconfig-domain-address-usb.c             |    2 +-
>  libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c      |    2 +-
>  libvirt-gconfig/libvirt-gconfig-domain-chardev-source-spicevmc.c |    2 +-
>  libvirt-gconfig/libvirt-gconfig-domain-controller-usb.c          |    2 +-
>  libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c            |    4 +---
>  libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c          |    4 +---
>  libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c            |    4 +---
>  libvirt-gconfig/libvirt-gconfig-domain-interface-bridge.c        |    4 +---
>  libvirt-gconfig/libvirt-gconfig-domain-interface-network.c       |    4 +---
>  libvirt-gconfig/libvirt-gconfig-domain-interface-user.c          |    4 +---
>  libvirt-gconfig/libvirt-gconfig-domain-timer-pit.c               |    2 +-
>  libvirt-gconfig/libvirt-gconfig-domain-timer-rtc.c               |    2 +-
>  13 files changed, 13 insertions(+), 25 deletions(-)
> 
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-address-pci.c b/libvirt-gconfig/libvirt-gconfig-domain-address-pci.c
> index 48e3872..5199b8a 100644
> --- a/libvirt-gconfig/libvirt-gconfig-domain-address-pci.c
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-address-pci.c
> @@ -67,7 +67,7 @@ GVirConfigDomainAddressPci *gvir_config_domain_address_pci_new_from_xml(const gc
>  
>      object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_ADDRESS_PCI,
>                                               "address", NULL, xml, error);
> -    gvir_config_object_set_attribute(object, "type", "pci", NULL);
> +    g_return_val_if_fail(g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "pci") != 0, NULL);

Self-NACK, this is an old version of this patch, which is leaking 'object'.

Christophe

Attachment: pgpL07pTPY7Ii.pgp
Description: PGP signature


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