]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virt-host-validate: Initialize the error object
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 8 Jun 2021 06:53:14 +0000 (08:53 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 9 Jun 2021 06:21:52 +0000 (08:21 +0200)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Fabiano Fidêncio <fabiano@fidencio.org>
tools/virt-host-validate.c

index c119d649ce3b8ad42a902c779214d3dc87506053..806d61bc8e161f7157cd4b155933d389c9556d16 100644 (file)
@@ -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) {