From 80678c4395db059ba28eb330bf59dc1ae433880d Mon Sep 17 00:00:00 2001 From: Arkadiusz Hiler Date: Wed, 5 May 2021 13:03:10 +0300 Subject: [PATCH] msvcrt: Make _beginthread() error out as documented. msvcrt_set_errno() seems to be doing the right thing in case of too many threads, invalid parameters, etc. Signed-off-by: Arkadiusz Hiler Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcrt/thread.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/msvcrt/thread.c b/dlls/msvcrt/thread.c index c2fc863dd33..8bf8d9327c1 100644 --- a/dlls/msvcrt/thread.c +++ b/dlls/msvcrt/thread.c @@ -118,6 +118,8 @@ uintptr_t CDECL _beginthread( TRACE("(%p, %d, %p)\n", start_address, stack_size, arglist); + if (!MSVCRT_CHECK_PMT(start_address)) return -1; + trampoline = malloc(sizeof(*trampoline)); if(!trampoline) { *_errno() = EAGAIN; @@ -128,7 +130,7 @@ uintptr_t CDECL _beginthread( trampoline, CREATE_SUSPENDED, NULL); if(!thread) { free(trampoline); - *_errno() = EAGAIN; + msvcrt_set_errno(GetLastError()); return -1; }