[Libvirt-cim] [PATCH] Fixing NullPointerException

Sharad Mishra snmishra at us.ibm.com
Wed Dec 29 22:18:41 UTC 2010


# HG changeset patch
# User Sharad Mishra <snmishra at us.ibm.com>
# Date 1293660976 28800
# Node ID a4f6fba67e8e85aaec6969c39cfaa016b60779d3
# Parent  35396e5b805193c024b6d4f065136d7b57a0b03d
Fixing NullPointerException

CMPIInstance 'inst' is used before it is set.
With this patch sending a one line change to
set previous instance correctly.

Signed-off-by: Sharad Mishra <snmishra at us.ibm.com>

diff -r 35396e5b8051 -r a4f6fba67e8e src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c	Tue Dec 14 13:59:51 2010 -0800
+++ b/src/Virt_VirtualSystemManagementService.c	Wed Dec 29 14:16:16 2010 -0800
@@ -1378,16 +1378,6 @@
                 goto out;
         }
 
-        if (cu_get_str_prop(inst, "autoStart", &autoStartFlag) != CMPI_RC_OK)
-                autoStartFlag = strdup("disable");
-        
-        if (STREQ(autoStartFlag, "enable"))
-                autoflag = 1;
-        else
-                autoflag = 0;  
-        if((virDomainSetAutostart(dom, autoflag)) == -1)
-                CU_DEBUG("Failed to set autostart flag.");
-
         name = virDomainGetName(dom);
 
         *s = get_domain_by_name(_BROKER, ref, name, &inst);
@@ -1396,6 +1386,20 @@
                 cu_statusf(_BROKER, s,
                            CMPI_RC_ERR_FAILED,
                            "Failed to lookup resulting system");
+                goto out;
+        }
+
+        if (inst != NULL) {
+                if (cu_get_str_prop(inst, "autoStart", 
+                    &autoStartFlag) != CMPI_RC_OK)
+                        autoStartFlag = strdup("disable");
+
+                if (STREQ(autoStartFlag, "enable"))
+                        autoflag = 1;
+                else
+                        autoflag = 0;
+                if((virDomainSetAutostart(dom, autoflag)) == -1)
+                        CU_DEBUG("Failed to set autostart flag.");
         }
 
  out:
@@ -2424,12 +2428,12 @@
                         goto out;
                 }
 
+                prev_inst = orig_inst;
                 s = cu_merge_instances(rasd, orig_inst);
                 if (s.rc != CMPI_RC_OK) {
                         CU_DEBUG("Failed to merge Instances");
                         goto out;
                 }
-                prev_inst = orig_inst;
                 rasd = orig_inst;
         
         } 




More information about the Libvirt-cim mailing list