From: Changbin Du <changbin.du@gmail.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org, Changbin Du <changbin.du@gmail.com>
Subject: [PATCH v2] ui/sdl2: fix segment fault caused by null pointer dereference
Date: Mon, 27 Apr 2020 21:24:12 +0800 [thread overview]
Message-ID: <20200427132412.17909-1-changbin.du@gmail.com> (raw)
I found SDL_GetWindowFromID() sometimes return NULL when I start qemu via
ssh forwarding even the window has been crated already. I am not sure
whether this is a bug of SDL, but we'd better check it carefully.
Signed-off-by: Changbin Du <changbin.du@gmail.com>
---
v2: fix typo.
---
ui/sdl2.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 3c9424eb42..61c7956da3 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -332,6 +332,10 @@ static void handle_keydown(SDL_Event *ev)
int gui_key_modifier_pressed = get_mod_state();
int gui_keysym = 0;
+ if (!scon) {
+ return;
+ }
+
if (!scon->ignore_hotkeys && gui_key_modifier_pressed && !ev->key.repeat) {
switch (ev->key.keysym.scancode) {
case SDL_SCANCODE_2:
@@ -412,6 +416,10 @@ static void handle_keyup(SDL_Event *ev)
{
struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
+ if (!scon) {
+ return;
+ }
+
scon->ignore_hotkeys = false;
sdl2_process_key(scon, &ev->key);
}
@@ -421,6 +429,10 @@ static void handle_textinput(SDL_Event *ev)
struct sdl2_console *scon = get_scon_from_window(ev->text.windowID);
QemuConsole *con = scon ? scon->dcl.con : NULL;
+ if (!con) {
+ return;
+ }
+
if (qemu_console_is_graphic(con)) {
return;
}
--
2.25.1
next reply other threads:[~2020-04-27 13:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 13:24 Changbin Du [this message]
2020-05-08 13:44 ` [PATCH v2] ui/sdl2: fix segment fault caused by null pointer dereference Changbin Du
2020-05-14 12:28 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200427132412.17909-1-changbin.du@gmail.com \
--to=changbin.du@gmail.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).