From 70b0d16c684364594443520fba504e665f167cc4 Mon Sep 17 00:00:00 2001 From: tangbinzy Date: Fri, 17 Nov 2023 09:38:56 +0000 Subject: [PATCH] vga: avoid crash if no default vga card mainline inclusion commit 6985d8ede92494f3b791de01e8ee9306eb6d5e4a category: bugfix --------------------------------------------------------------- QEMU in some arch will crash when executing -vga help command, because there is no default vga model. Add check to this case and avoid crash. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/978 Signed-off-by: Guo Zhi Reviewed-by: Thomas Huth Tested-by: Thomas Huth Message-Id: <20220503091724.970009-1-qtxuning1999@sjtu.edu.cn> Signed-off-by: Laurent Vivier Signed-off-by: tangbinzy --- softmmu/vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index d8996f3d6e..e34c8a0646 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -974,7 +974,8 @@ static void select_vgahw(const MachineClass *machine_class, const char *p) if (vga_interface_available(t) && ti->opt_name) { printf("%-20s %s%s\n", ti->opt_name, ti->name ?: "", - g_str_equal(ti->opt_name, def) ? " (default)" : ""); + (def && g_str_equal(ti->opt_name, def)) ? + " (default)" : ""); } } exit(0); -- 2.27.0