[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PATCH v2] main-loop: Fix SetEvent() on uninitialized han
From: |
Michael Roth |
Subject: |
[Qemu-trivial] [PATCH v2] main-loop: Fix SetEvent() on uninitialized handle on win32 |
Date: |
Fri, 27 Jan 2012 08:52:01 -0600 |
The __attribute__((constructor)) init_main_loop() automatically get
called if qemu-tool.o is linked in. On win32, this leads to
a qemu_notify_event() call which attempts to SetEvent() on a HANDLE that
won't be initialized until qemu_init_main_loop() is manually called,
breaking qemu-tools.o programs on Windows at runtime.
This patch checks for an initialized event handle before attempting to
set it, which is analoguous to how we deal with an unitialized
io_thread_fd in the posix implementation.
Signed-off-by: Michael Roth <address@hidden>
---
main-loop.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/main-loop.c b/main-loop.c
index 692381c..db90ace 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -183,6 +183,9 @@ static int qemu_event_init(void)
void qemu_notify_event(void)
{
+ if (!qemu_event_handle) {
+ return;
+ }
if (!SetEvent(qemu_event_handle)) {
fprintf(stderr, "qemu_notify_event: SetEvent failed: %ld\n",
GetLastError());
--
1.7.4.1