So I ran an Analyze in VS 2017 with my C++ code. It gives me a buffer overrun with the following:
TCHAR *sTemp = new TCHAR[5]();
if (sTemp)
StringCchCopy(sTemp, 5, L"0123456789");
When I step through the code, sTemp is "0123", with the 4th position of course being \0.
When I run Analyze on the code, I get the C6386 error:
Warning C6386 Buffer overrun while writing to 'sTemp': the writable size is 'unsigned int' bytes, but '10' bytes might be written.
Why? I have also tried changing the array to 10 and the StringCchCopy to 5 and still the same error.