qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH RFC v3 6/7] qemu_thread_join: fix segmentation f


From: Fei Li
Subject: Re: [Qemu-devel] [PATCH RFC v3 6/7] qemu_thread_join: fix segmentation fault
Date: Thu, 20 Sep 2018 12:51:24 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1



On 09/19/2018 11:14 PM, Fam Zheng wrote:
On Wed, 09/19 21:35, Fei Li wrote:
To avoid the segmentation fault in qemu_thread_join(), just directly
return when the QemuThread *thread was failed to be created in both
qemu-thread-posix.c and qemu-thread-win32.c.
Per English grammar, I think "when the QemuThread *thread failed to be created
in either qemu-thread-posix.c or qemu-thread-win32.c" sounds better.
Thanks for the comment, much better. :)

Have a nice day
Fei

Signed-off-by: Fei Li <address@hidden>
---
  util/qemu-thread-posix.c | 3 +++
  util/qemu-thread-win32.c | 2 +-
  2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index dfa66ff2fb..289af4fab5 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -562,6 +562,9 @@ void *qemu_thread_join(QemuThread *thread)
      int err;
      void *ret;
+ if (!thread->thread) {
+        return NULL;
+    }
      err = pthread_join(thread->thread, &ret);
      if (err) {
          error_exit(err, __func__);
diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c
index 4a363ca675..1a27e1cf6f 100644
--- a/util/qemu-thread-win32.c
+++ b/util/qemu-thread-win32.c
@@ -366,7 +366,7 @@ void *qemu_thread_join(QemuThread *thread)
      HANDLE handle;
data = thread->data;
-    if (data->mode == QEMU_THREAD_DETACHED) {
+    if (data == NULL || data->mode == QEMU_THREAD_DETACHED) {
          return NULL;
      }
--
2.13.7

Reviewed-by: Fam Zheng <address@hidden>








reply via email to

[Prev in Thread] Current Thread [Next in Thread]