Onega

a lot of VC++ posts, a few C# posts, and some miscellaneous stuff

Friday, March 31, 2006

double free an interface leads to serious error.

The following code leads to application error "The instruction at "0x00000000" referenced memory at "0x00000000". The memory could not be "read". and the error can't be caught by VC++ 8.0 although I am running module of debug version.
But it is detected by BoundsChecker 2005 after I rebuilt it with BoundsChecker enabled.

IErrorInfoPtr pEI = NULL; // must use native pointer, DON'T USE com smart pointer
if(SUCCEEDED((spER->GetErrorInfo (ulRecordNum, GetUserDefaultLCID(), &pEI))))
{
_com_error tmp_error(0, pEI, false); // "false" shall come with a native pointer
if(tmp_error.Description().length())
ts_tmp<<(LPCTSTR)tmp_error.Description()<<std::endl;
}
in fact the bad version is _com_error tmp_error(0, pEI);

0 Comments:

Post a Comment

<< Home