diff --git a/libraries/AP_HAL_SITL/Scheduler.cpp b/libraries/AP_HAL_SITL/Scheduler.cpp index 8207994e1b..75af56b7d7 100644 --- a/libraries/AP_HAL_SITL/Scheduler.cpp +++ b/libraries/AP_HAL_SITL/Scheduler.cpp @@ -323,8 +323,10 @@ bool Scheduler::thread_create(AP_HAL::MemberProc proc, const char *name, uint32_ a->stack_size = stack_size; a->f[0] = proc; a->name = name; - - pthread_attr_init(&a->attr); + + if (pthread_attr_init(&a->attr) != 0) { + goto failed; + } #if SITL_STACK_CHECKING_ENABLED if (pthread_attr_setstack(&a->attr, a->stack, alloc_stack) != 0) { AP_HAL::panic("Failed to set stack of size %u for thread %s", alloc_stack, name);