[Libguestfs] [PATCH] RHEV: Ensure DESTROY won't be called for uninitialized object

Richard W.M. Jones rjones at redhat.com
Mon Jan 17 16:14:03 UTC 2011


On Mon, Jan 17, 2011 at 04:06:00PM +0000, Matthew Booth wrote:
> Fixes RHBZ#615182
> ---
>  lib/Sys/VirtV2V/Connection/RHEVTarget.pm |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/Sys/VirtV2V/Connection/RHEVTarget.pm b/lib/Sys/VirtV2V/Connection/RHEVTarget.pm
> index c9dd148..b63d956 100644
> --- a/lib/Sys/VirtV2V/Connection/RHEVTarget.pm
> +++ b/lib/Sys/VirtV2V/Connection/RHEVTarget.pm
> @@ -442,9 +442,7 @@ sub new
>      my $class = shift;
>      my ($domain_path) = @_;
>  
> -    my $self = {};
> -    bless($self, $class);
> -
> +    # Must do this before bless, or DESTROY will be called
>      die(user_message(__"You must be root to output to RHEV"))
>          unless ($> == 0);
>  
> @@ -456,6 +454,9 @@ sub new
>                                  "36:36",
>                                  mountdir => $mountdir)));
>  
> +    my $self = {};
> +    bless($self, $class);
> +
>      $self->{mountdir} = $mountdir;
>      $self->{domain_path} = $domain_path;

ACK, perfectly sensible.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v




More information about the Libguestfs mailing list