[PATCH 1/5] virt-host-validate: Initialize the error object
Michal Privoznik
mprivozn at redhat.com
Tue Jun 8 08:45:06 UTC 2021
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 at redhat.com>
---
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
More information about the libvir-list
mailing list