qemu-char: Fix crash when switching consoles

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>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Stefan Weil 2012-04-19 22:27:14 +02:00 committed by Anthony Liguori
parent 023d3d67c7
commit ac3107340f

View File

@ -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)