From 815dff31cdfcaf088b9c8ae4a176a1c62813ada8 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 3 Sep 2022 14:07:45 +0200 Subject: [PATCH] gthread: Check if memory allocation was successful --- libraries/wutstdc++/wut_gthread_thread.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/wutstdc++/wut_gthread_thread.cpp b/libraries/wutstdc++/wut_gthread_thread.cpp index 5cc0c8304..614040939 100644 --- a/libraries/wutstdc++/wut_gthread_thread.cpp +++ b/libraries/wutstdc++/wut_gthread_thread.cpp @@ -24,9 +24,16 @@ __wut_thread_create(OSThread **outThread, void *entryArgs) { OSThread *thread = (OSThread *)memalign(16, sizeof(OSThread)); - char *stack = (char *)memalign(16, __WUT_STACK_SIZE); + if (!thread) { + return ENOMEM; + } memset(thread, 0, sizeof(OSThread)); + char *stack = (char *)memalign(16, __WUT_STACK_SIZE); + if (!stack) { + return ENOMEM; + } + if (!OSCreateThread(thread, (OSThreadEntryPointFn)entryPoint, (int)entryArgs,