Fixed use after free.
authorArmin Novak <armin.novak@gmail.com>
Sun, 16 Nov 2014 14:21:13 +0000 (15:21 +0100)
committerArmin Novak <armin.novak@gmail.com>
Sun, 16 Nov 2014 14:21:13 +0000 (15:21 +0100)
winpr/libwinpr/thread/thread.c

index da9d86b..8916f22 100644 (file)
@@ -426,6 +426,7 @@ HANDLE CreateRemoteThread(HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttribu
 
 VOID ExitThread(DWORD dwExitCode)
 {
+       DWORD rc;
        pthread_t tid = pthread_self();
 
        if (!thread_list)
@@ -460,10 +461,11 @@ VOID ExitThread(DWORD dwExitCode)
                ListDictionary_Unlock(thread_list);
                set_event(thread);
 
+               rc = thread->dwExitCode;
                if (thread->detached || !thread->started)
                        cleanup_handle(thread);
 
-               pthread_exit((void*) (size_t) thread->dwExitCode);
+               pthread_exit((void*) (size_t) rc);
        }
 }