* [PATCH v2] ui/sdl2: fix segment fault caused by null pointer dereference
@ 2020-04-27 13:24 Changbin Du
2020-05-08 13:44 ` Changbin Du
0 siblings, 1 reply; 3+ messages in thread
From: Changbin Du @ 2020-04-27 13:24 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel, Changbin Du
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ui/sdl2: fix segment fault caused by null pointer dereference
2020-04-27 13:24 [PATCH v2] ui/sdl2: fix segment fault caused by null pointer dereference Changbin Du
@ 2020-05-08 13:44 ` Changbin Du
2020-05-14 12:28 ` Gerd Hoffmann
0 siblings, 1 reply; 3+ messages in thread
From: Changbin Du @ 2020-05-08 13:44 UTC (permalink / raw)
To: Changbin Du; +Cc: Gerd Hoffmann, qemu-devel
hello, is this ready to merge now?
On Mon, Apr 27, 2020 at 09:24:12PM +0800, Changbin Du wrote:
> 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
>
--
Cheers,
Changbin Du
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ui/sdl2: fix segment fault caused by null pointer dereference
2020-05-08 13:44 ` Changbin Du
@ 2020-05-14 12:28 ` Gerd Hoffmann
0 siblings, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2020-05-14 12:28 UTC (permalink / raw)
To: Changbin Du; +Cc: qemu-devel
On Fri, May 08, 2020 at 09:44:24PM +0800, Changbin Du wrote:
> hello, is this ready to merge now?
>
> On Mon, Apr 27, 2020 at 09:24:12PM +0800, Changbin Du wrote:
> > 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>
Added to ui queue now.
thanks,
Gerd
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-14 12:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27 13:24 [PATCH v2] ui/sdl2: fix segment fault caused by null pointer dereference Changbin Du
2020-05-08 13:44 ` Changbin Du
2020-05-14 12:28 ` Gerd Hoffmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.