aboutsummaryrefslogtreecommitdiff
path: root/iohandler.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-09-07 13:44:45 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2011-09-08 08:06:08 -0500
commitc82dc29a9112f34e0a51cad9a412cf6d9d05dfb2 (patch)
treeb6498e6e1102256b88abbf9ee3e77cc2d28abdfa /iohandler.c
parent344eecf6995f4a0ad1d887cec922f6806f91a3f8 (diff)
downloadqemu-arm-c82dc29a9112f34e0a51cad9a412cf6d9d05dfb2.tar.gz
iohandlers: fix issue with qemu_set_fd_handler()
As spotted by Aneesh, some users pass a NULL opaque so we need to be more aggressive in checking whether a user means to unregister. Also fix a double free caused by tag not being reset to zero after delete. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'iohandler.c')
-rw-r--r--iohandler.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/iohandler.c b/iohandler.c
index 5ef66fb6e8..4cc1c5ade6 100644
--- a/iohandler.c
+++ b/iohandler.c
@@ -93,10 +93,6 @@ static gboolean fd_trampoline(GIOChannel *chan, GIOCondition cond, gpointer opaq
{
IOTrampoline *tramp = opaque;
- if (tramp->opaque == NULL) {
- return FALSE;
- }
-
if ((cond & G_IO_IN) && tramp->fd_read) {
tramp->fd_read(tramp->opaque);
}
@@ -119,9 +115,10 @@ int qemu_set_fd_handler(int fd,
if (tramp->tag != 0) {
g_io_channel_unref(tramp->chan);
g_source_remove(tramp->tag);
+ tramp->tag = 0;
}
- if (opaque) {
+ if (fd_read || fd_write || opaque) {
GIOCondition cond = 0;
tramp->fd_read = fd_read;