Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,10 @@ ClrDataAccess::GetRegisterName(int regNum, unsigned int count, _Inout_updates_z_
return E_UNEXPECTED;

const WCHAR callerPrefix[] = W("caller.");
unsigned int prefixLen = (unsigned int)ARRAY_SIZE(callerPrefix) - 1;
unsigned int regLen = (unsigned int)wcslen(regs[regNum]);
unsigned int needed = (callerFrame?prefixLen:0) + regLen + 1;
// Include null terminator in prefixLen/regLen because wcscpy_s will fail otherwise
unsigned int prefixLen = (unsigned int)ARRAY_SIZE(callerPrefix);
unsigned int regLen = (unsigned int)wcslen(regs[regNum]) + 1;
unsigned int needed = (callerFrame ? prefixLen - 1 : 0) + regLen;
if (pNeeded)
*pNeeded = needed;

Expand All @@ -662,6 +663,8 @@ ClrDataAccess::GetRegisterName(int regNum, unsigned int count, _Inout_updates_z_
{
unsigned int toCopy = prefixLen < destSize ? prefixLen : destSize;
wcscpy_s(curr, toCopy, callerPrefix);
// Point to null terminator
toCopy--;
curr += toCopy;
destSize -= toCopy;
}
Expand All @@ -670,6 +673,8 @@ ClrDataAccess::GetRegisterName(int regNum, unsigned int count, _Inout_updates_z_
{
unsigned int toCopy = regLen < destSize ? regLen : destSize;
wcscpy_s(curr, toCopy, regs[regNum]);
// Point to null terminator
toCopy--;
curr += toCopy;
destSize -= toCopy;
}
Expand Down