thread: Check sysconf value before using it

sysconf() is documented as returning -1 if it can't determine
a minimum thread stack size. Check for this case before using
the return value.

https://bugzilla.gnome.org/show_bug.cgi?id=739122
This commit is contained in:
Mattias Ellert 2014-10-24 12:29:00 +00:00 committed by Matthias Clasen
parent 916297be79
commit f7b13e05f9

View File

@ -1159,7 +1159,9 @@ g_system_thread_new (GThreadFunc thread_func,
if (stack_size)
{
#ifdef _SC_THREAD_STACK_MIN
stack_size = MAX (sysconf (_SC_THREAD_STACK_MIN), stack_size);
long min_stack_size = sysconf (_SC_THREAD_STACK_MIN);
if (min_stack_size >= 0)
stack_size = MAX (min_stack_size, stack_size);
#endif /* _SC_THREAD_STACK_MIN */
/* No error check here, because some systems can't do it and
* we simply don't want threads to fail because of that. */