[PATCH] ui: return NULL when getting cursor without a console

marcandre.lureau@redhat.com posted 1 patch 1 year ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230428154807.2143652-1-marcandre.lureau@redhat.com
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>
ui/console.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] ui: return NULL when getting cursor without a console
Posted by marcandre.lureau@redhat.com 1 year ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

VNC may try to get the current cursor even when there are no consoles
and crashes. Simple reproducer is qemu with -nodefaults.

Fixes: (again)
https://gitlab.com/qemu-project/qemu/-/issues/1548

Fixes: commit 385ac97f8 ("ui: keep current cursor with QemuConsole")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/console.c b/ui/console.c
index cbd60cc473..aefa43a1a4 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -2341,7 +2341,7 @@ QEMUCursor *qemu_console_get_cursor(QemuConsole *con)
     if (con == NULL) {
         con = active_console;
     }
-    return con->cursor;
+    return con ? con->cursor : NULL;
 }
 
 bool qemu_console_is_visible(QemuConsole *con)
-- 
2.40.0


Re: [PATCH] ui: return NULL when getting cursor without a console
Posted by Philippe Mathieu-Daudé 1 year ago
On 28/4/23 17:48, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> VNC may try to get the current cursor even when there are no consoles
> and crashes. Simple reproducer is qemu with -nodefaults.
> 
> Fixes: (again)
> https://gitlab.com/qemu-project/qemu/-/issues/1548
> 
> Fixes: commit 385ac97f8 ("ui: keep current cursor with QemuConsole")
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   ui/console.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>