[PATCH 1/5] virt-host-validate: Initialize the error object

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

 



Several libvirt functions are called from virt-host-validate.
Some of these functions do report an error on failure. But
reporting an error is coupled with freeing previous error (by
calling virResetError()). But we've never called
virErrorInitialize() and thus resetting error object frees some
random pointer.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tools/virt-host-validate.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/virt-host-validate.c b/tools/virt-host-validate.c
index c119d649ce..806d61bc8e 100644
--- a/tools/virt-host-validate.c
+++ b/tools/virt-host-validate.c
@@ -27,6 +27,7 @@
 #include <getopt.h>
 
 #include "internal.h"
+#include "virerror.h"
 #include "virgettext.h"
 
 #include "virt-host-validate-common.h"
@@ -83,8 +84,11 @@ main(int argc, char **argv)
     bool quiet = false;
     bool usedHvname = false;
 
-    if (virGettextInitialize() < 0)
+    if (virGettextInitialize() < 0 ||
+        virErrorInitialize() < 0) {
+        fprintf(stderr, _("%s: initialization failed\n"), argv[0]);
         return EXIT_FAILURE;
+    }
 
     while ((c = getopt_long(argc, argv, "hvq", argOptions, NULL)) != -1) {
         switch (c) {
-- 
2.31.1




[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]

  Powered by Linux