[Libvirt-cim] [PATCH 14/19] Coverity: Resolve REVERSE_INULL - doms_to_xml()

John Ferlan jferlan at redhat.com
Thu May 16 14:57:49 UTC 2013


(1) Event deref_ptr:
    Directly dereferencing pointer "dom_xml_list".

436             *dom_xml_list = calloc(dom_ptr_count, sizeof(struct dom_xml));

(2) Event check_after_deref:
    Null-checking "dom_xml_list" suggests that it may be null, but it has
    already been dereferenced on all paths leading to the check.

437             if (!dom_xml_list) {

Resolve by changing check to be "if (!*dom_xml_list) {"
---
 src/Virt_ComputerSystemIndication.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Virt_ComputerSystemIndication.c b/src/Virt_ComputerSystemIndication.c
index e9fa0c2..1ae8193 100644
--- a/src/Virt_ComputerSystemIndication.c
+++ b/src/Virt_ComputerSystemIndication.c
@@ -434,7 +434,7 @@ static CMPIStatus doms_to_xml(struct dom_xml **dom_xml_list,
                 return s;
         }
         *dom_xml_list = calloc(dom_ptr_count, sizeof(struct dom_xml));
-        if (!dom_xml_list) {
+        if (!*dom_xml_list) {
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
                            "Failed calloc %d dom_xml.", dom_ptr_count);
-- 
1.8.1.4




More information about the Libvirt-cim mailing list