I've got an wide char string , where the content of it is read from a rich edit control. Because the corrupted content of strKeyW, application lately crashes ; and unfortunately I can't check why exactly invalid data is written to it (the current debugging comes from a DUMP file and I can't reproduce the crash by myself on my local computer neither on the test environment). Anyway, is it there any method(s) that could help me to validate the strKeyW so I can avoid future use of unreadable memory ?
LPWSTR strKeyW = new WCHAR[nLength];
m_HiddenRTFCtrl.SendMessage(EM_GETSELTEXT, (WPARAM)0, (LPARAM)strKeyW);