[PATCH 6/7] util: Resolve Coverity FORWARD_NULL

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

 



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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]