From e7ae82dcc523d333933c90e20cdeb25d747ad1b3 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 8 Jun 2021 08:53:14 +0200 Subject: [PATCH] virt-host-validate: Initialize the error object MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko Reviewed-by: Fabiano Fidêncio --- 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 #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.47.2