title: Unreadable memory validation
body: <p>I've got an wide char string , where the content of it is read from a rich edit control. Because the corrupted content of <strong>strKeyW</strong>, 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 <strong>strKeyW</strong> so I can avoid future use of unreadable memory ?</p>
  
  <pre><code>LPWSTR strKeyW = new WCHAR[nLength];
  m_HiddenRTFCtrl.SendMessage(EM_GETSELTEXT, (WPARAM)0, (LPARAM)strKeyW);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/bXTvA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bXTvA.png" alt="Content of strKeyW"></a></p>