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....@rustyne.lautre.net>
Signed-off-by: Antonin Décimo <anto...@tarides.com>
---
 mingw-w64-libraries/winpthreads/src/thread.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-libraries/winpthreads/src/thread.c 
b/mingw-w64-libraries/winpthreads/src/thread.c
index dc8b82515..b4bb2f048 100644
--- a/mingw-w64-libraries/winpthreads/src/thread.c
+++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -1607,9 +1607,12 @@ pthread_create (pthread_t *th, const pthread_attr_t 
*attr, void *(* func)(void *
   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 @@ pthread_create (pthread_t *th, const pthread_attr_t 
*attr, void *(* func)(void *
     {
       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)
        {
-- 
2.43.0



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to