summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-08-21 18:40:52 +0200
committerwm4 <wm4@nowhere>2017-08-21 18:42:04 +0200
commit0bfeba2d9a0f7d76e3a93ec79734c50512ea7048 (patch)
treec55960e6997fb4a1aac86d45d4fb911e2d20077b /osdep
parentd431111b0647278d2bc234e9e6551c0b7e6c2b6f (diff)
downloadmpv-0bfeba2d9a0f7d76e3a93ec79734c50512ea7048.tar.bz2
mpv-0bfeba2d9a0f7d76e3a93ec79734c50512ea7048.tar.xz
win32: fix massive memory corruption (take 2)
As pointed out by uau on IRC, the pointer to info is still used outside of the lock. An extremely small race condition window, but still a race condition.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/win32/pthread.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/osdep/win32/pthread.c b/osdep/win32/pthread.c
index d4a5ddc22a..141ecfc5e0 100644
--- a/osdep/win32/pthread.c
+++ b/osdep/win32/pthread.c
@@ -206,11 +206,12 @@ int pthread_detach(pthread_t thread)
static DWORD WINAPI run_thread(LPVOID lpParameter)
{
pthread_mutex_lock(&pthread_table_lock);
- struct m_thread_info *info = find_thread_info(pthread_self());
- assert(info);
+ struct m_thread_info *pinfo = find_thread_info(pthread_self());
+ assert(pinfo);
+ struct m_thread_info info = *pinfo;
pthread_mutex_unlock(&pthread_table_lock);
- pthread_exit(info->user_fn(info->user_arg));
+ pthread_exit(info.user_fn(info.user_arg));
abort(); // not reached
}