I have a simple question.
I have following piece of code in a sample MFC application:
void CSampleAppDlg::OnButton1()
{
try
{ char e[1];
strcpy(e,"asdsadadsadsadsdsasdadsasdasdasadsadsads adsadsaad");
}
catch(...)
{
::OutputDebugString("Error");
}
}
the application disappears without any error. I don't even see the
trace string
Yes, the stack got corrupted . I tried to use SEH
__try {
char e[1];
strcpy(e,"asdsadadsadsadsdsasdadsasdasdasadsadsads adsadsaad");
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
::OutputDebugString("Error");
}
still same behavior...
However when I try
__try {
char e[1];
strcpy(e,"A very long string to test stack corruption.........test
stack corruption.........");
}
finally {
::OutputDebugString("Error");
}
I see "Error" in the debug trace...
My question is this:
What should I do to catch an error like that in an application
Is there anything I can do so that I can catch such an error where it
happens without the application disappearing?