winpthreads: Check if requested stack size fits in an unsigned int The requested stack size is a `size_t`, whereas _beginthreadex takes an `unsigned int`. This provides a bit of input sanitation, and prevents a compiler warning. Co-authored-by: Samuel Hym <samuel.hym@rustyne.lautre.net> Signed-off-by: Antonin Décimo <antonin@tarides.com> Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-libraries/winpthreads/src/thread.c b/mingw-w64-libraries/winpthreads/src/thread.c index dc8b825..b4bb2f0 100644 --- a/mingw-w64-libraries/winpthreads/src/thread.c +++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -1607,9 +1607,12 @@ HANDLE thrd = NULL; int redo = 0; struct _pthread_v *tv; - size_t ssize = 0; + unsigned int ssize = 0; pthread_spinlock_t new_spin_keys = PTHREAD_SPINLOCK_INITIALIZER; + if (attr && attr->s_size > UINT_MAX) + return EINVAL; + if ((tv = pop_pthread_mem ()) == NULL) return EAGAIN; @@ -1649,7 +1652,7 @@ { int inh = 0; tv->p_state = attr->p_state; - ssize = attr->s_size; + ssize = (unsigned int)attr->s_size; pthread_attr_getinheritsched (attr, &inh); if (inh) {