From 6467f56abfa0b65e1670ddffd77bbe307cb6e1d4 Mon Sep 17 00:00:00 2001 From: int_szyk Date: Wed, 21 Aug 2019 13:05:47 +0200 Subject: [PATCH] Fix Coverity uninitialized pointer field Thread.h Changed _obj_mem to be initialized with constructor of new thread. --- rtos/source/Thread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rtos/source/Thread.cpp b/rtos/source/Thread.cpp index 1a7a5f13773..0d43391e495 100644 --- a/rtos/source/Thread.cpp +++ b/rtos/source/Thread.cpp @@ -51,7 +51,8 @@ void Thread::constructor(uint32_t tz_module, osPriority priority, const uint32_t offset = aligned_mem - unaligned_mem; const uint32_t aligned_size = ALIGN_DOWN(stack_size - offset, 8); - _tid = 0; + memset(&_obj_mem, 0, sizeof(_obj_mem)); + _tid = nullptr; _dynamic_stack = (stack_mem == nullptr); _finished = false; memset(&_attr, 0, sizeof(_attr)); @@ -106,7 +107,6 @@ osStatus Thread::start(mbed::Callback task) ((uint32_t *)_attr.stack_mem)[i] = osRtxStackMagicWord; } - memset(&_obj_mem, 0, sizeof(_obj_mem)); _attr.cb_size = sizeof(_obj_mem); _attr.cb_mem = &_obj_mem; _task = task;