diff --git a/libraries/AP_HAL_SITL/Scheduler.cpp b/libraries/AP_HAL_SITL/Scheduler.cpp index 7bdcc2ea89..1f49d254a9 100644 --- a/libraries/AP_HAL_SITL/Scheduler.cpp +++ b/libraries/AP_HAL_SITL/Scheduler.cpp @@ -267,7 +267,9 @@ bool Scheduler::thread_create(AP_HAL::MemberProc proc, const char *name, uint32_ if (!a->f) { goto failed; } - posix_memalign(&a->stack, 4096, alloc_stack); + if (posix_memalign(&a->stack, 4096, alloc_stack) != 0) { + goto failed; + } if (!a->stack) { goto failed; }