[libvirt] [PATCH 6/7] util: Resolve Coverity FORWARD_NULL

John Ferlan jferlan at redhat.com
Wed Jul 1 14:03:50 UTC 2015


Coverity "believes" that virDBusMessageIterDecode could find "nstack = 0"
in the first pass through the "for (;;)", thus break'ing out of the loop
prior to any virDBusTypeStackPush being called thus having 'stack == NULL'.

Rather than check for (!stack) prior to either the Encode or Decode path,
putting a (!*stack) in the StackFree ensures we don't have some sort of
NULL deref

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/util/virdbus.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index 1cf1eef..78fb795 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -544,6 +544,10 @@ static void virDBusTypeStackFree(virDBusTypeStack **stack,
                                  size_t *nstack)
 {
     size_t i;
+
+    if (!*stack)
+        return;
+
     /* The iter in the first level of the stack is the
      * root iter which must not be freed
      */
-- 
2.1.0




More information about the libvir-list mailing list