According to the documentation for _snprintf_s(), if _TRUNCATE is passed as the count parameter then the output string should be truncated to the length of the buffer and a null terminator appended. However, when _TRUNCATE is passed as the count parameter the function actually writes a null terminator 2 bytes before the beginning of the destination string. This array out of bounds access triggers the stack corruption detection when basic runtime checks are enabled.
Version