diff mbox

qemu-char: Fix crash when switching consoles

Message ID 1334867234-22885-1-git-send-email-sw@weilnetz.de
State Accepted
Headers show

Commit Message

Stefan Weil April 19, 2012, 8:27 p.m. UTC
qemu-system-arm (and other system emulations) crashes with SDL when
the user switches consoles (Alt-Ctrl-F4).

We already check for NULL pointers in qemu_chr_fe_ioctl,
qemu_chr_be_can_write and other functions, so do this also
for s->chr_read in qemu_chr_be_write. This fixes the crash.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 qemu-char.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Comments

Anthony Liguori April 24, 2012, 6:24 p.m. UTC | #1
On 04/19/2012 03:27 PM, Stefan Weil wrote:
> qemu-system-arm (and other system emulations) crashes with SDL when
> the user switches consoles (Alt-Ctrl-F4).
>
> We already check for NULL pointers in qemu_chr_fe_ioctl,
> qemu_chr_be_can_write and other functions, so do this also
> for s->chr_read in qemu_chr_be_write. This fixes the crash.
>
> Signed-off-by: Stefan Weil<sw@weilnetz.de>

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   qemu-char.c |    4 +++-
>   1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/qemu-char.c b/qemu-char.c
> index 287e195..43adcb2 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -160,7 +160,9 @@ int qemu_chr_be_can_write(CharDriverState *s)
>
>   void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len)
>   {
> -    s->chr_read(s->handler_opaque, buf, len);
> +    if (s->chr_read) {
> +        s->chr_read(s->handler_opaque, buf, len);
> +    }
>   }
>
>   int qemu_chr_fe_get_msgfd(CharDriverState *s)
diff mbox

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 287e195..43adcb2 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -160,7 +160,9 @@  int qemu_chr_be_can_write(CharDriverState *s)
 
 void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len)
 {
-    s->chr_read(s->handler_opaque, buf, len);
+    if (s->chr_read) {
+        s->chr_read(s->handler_opaque, buf, len);
+    }
 }
 
 int qemu_chr_fe_get_msgfd(CharDriverState *s)