The functions uses EACCESS for insufficient resources, so we cannot leave errno set by malloc().
msvcrt_set_errno() seems to be doing the right thing in case of too many threads, invalid parameters, etc.
Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com --- dlls/msvcrt/thread.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcrt/thread.c b/dlls/msvcrt/thread.c index c2fc863dd33..3ab53166192 100644 --- a/dlls/msvcrt/thread.c +++ b/dlls/msvcrt/thread.c @@ -118,9 +118,14 @@ uintptr_t CDECL _beginthread(
TRACE("(%p, %d, %p)\n", start_address, stack_size, arglist);
+ if(!start_address) { + *_errno() = EINVAL; + return -1; + } + trampoline = malloc(sizeof(*trampoline)); if(!trampoline) { - *_errno() = EAGAIN; + *_errno() = EACCES; return -1; }
@@ -128,7 +133,7 @@ uintptr_t CDECL _beginthread( trampoline, CREATE_SUSPENDED, NULL); if(!thread) { free(trampoline); - *_errno() = EAGAIN; + msvcrt_set_errno(GetLastError()); return -1; }