Skip to content

Commit 1176020

Browse files
bzbarsky-applepull[bot]
authored andcommitted
Fix thread names for k32w's DiagnosticDataProvider. (#26892)
The old code was copying in N-1 chars, then creating a string of length N from them, so ending up with a random byte in the string, which could lead to the string not being valid UTF-8. Fixes #26891
1 parent 0d53614 commit 1176020

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetThreadMetrics(ThreadMetrics ** threadM
110110
{
111111
ThreadMetrics * thread = (ThreadMetrics *) pvPortMalloc(sizeof(ThreadMetrics));
112112

113-
strncpy(thread->NameBuf, taskStatusArray[x].pcTaskName, kMaxThreadNameLength - 1);
114-
thread->NameBuf[kMaxThreadNameLength] = '\0';
113+
Platform::CopyString(thread->NameBuf, taskStatusArray[x].pcTaskName);
115114
thread->name.Emplace(CharSpan::fromCharString(thread->NameBuf));
116115
thread->id = taskStatusArray[x].xTaskNumber;
117116

0 commit comments

Comments
 (0)