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

Matthew Booth mbooth at redhat.com
Mon Jan 17 16:06:00 UTC 2011


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;
 
-- 
1.7.3.4




More information about the Libguestfs mailing list