2

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);

Content of strKeyW

3
  • Possibly relevant: stackoverflow.com/questions/1806297/… Commented Feb 13, 2020 at 14:18
  • 2
    Where does nLength come from? Is it large enough to hold the text from the control, including the terminating NUL character? You can check that against the return value from SendMessage. Commented Feb 13, 2020 at 14:19
  • About nLength , no , it's not large enough to hold the data (at least I suppose so) , but it's neither 0 or negative value. But what's more strange I know the source where from the data is included in m_HiddenRTFCtrl , and after any test on local machine this sendmessage didn't failed. Also it's possible that the Dump file is .. I don't know , maybe not accurate . For any cases I want to add a validation function , at least till I don't get any more dumps or data from client. So far my question is still if I can avoid any other situations like this one by checking the incoming string. Commented Feb 13, 2020 at 16:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.