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

[libvirt] ESX [11/12]: Reorder some function calls to avoid potential virDomainPtr leaks



* src/esx/esx_driver.c: avoid potential virDomainPtr leaks
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 5a93d1f..91de407 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -1200,14 +1200,14 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
             continue;
         }
 
-        domain = virGetDomain(conn, name_candidate, uuid_candidate);
-
-        if (domain == NULL) {
+        if (esxVI_GetVirtualMachinePowerState(conn, virtualMachine,
+                                              &powerState) < 0) {
             goto failure;
         }
 
-        if (esxVI_GetVirtualMachinePowerState(conn, virtualMachine,
-                                              &powerState) < 0) {
+        domain = virGetDomain(conn, name_candidate, uuid_candidate);
+
+        if (domain == NULL) {
             goto failure;
         }
 
@@ -1291,14 +1291,14 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
             continue;
         }
 
-        domain = virGetDomain(conn, name_candidate, uuid_candidate);
-
-        if (domain == NULL) {
+        if (esxVI_GetVirtualMachinePowerState(conn, virtualMachine,
+                                              &powerState) < 0) {
             goto failure;
         }
 
-        if (esxVI_GetVirtualMachinePowerState(conn, virtualMachine,
-                                              &powerState) < 0) {
+        domain = virGetDomain(conn, name_candidate, uuid_candidate);
+
+        if (domain == NULL) {
             goto failure;
         }
 

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