G
Guest
Hello,
My application is using a Dll loaded with the function
"LoadLibrary(<NameOfTheDll>)"
In the dll there is the following fonction :
char * GetMessageError(int Error)
{
char * pMessageError;
CString ErrorMessage;
(...)// filling of Error message
pMessageError= new char[ErrorMessage.GetLength()+1];
strcpy_s(pMessageError,ErrorMessage.GetLength()+1,ErrorMessage.GetBuffer());
return pMessageError;
}
In my application there is the function :
void DisplayMessageError(int DllError)
{
char * pMessageError= GetMessageError(DllError);
if(pMessageError){
AfxMessageBox(pMessageError);
delete pMessageError;//!!!!!!!!!!!---------->Problem at this line
}
}
In debug mode when executing the line 'delete pMessageError'
I have the following assertion
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
The Dll seems to have its own heap.
How can I solve this problem ?
JsCHarly
My application is using a Dll loaded with the function
"LoadLibrary(<NameOfTheDll>)"
In the dll there is the following fonction :
char * GetMessageError(int Error)
{
char * pMessageError;
CString ErrorMessage;
(...)// filling of Error message
pMessageError= new char[ErrorMessage.GetLength()+1];
strcpy_s(pMessageError,ErrorMessage.GetLength()+1,ErrorMessage.GetBuffer());
return pMessageError;
}
In my application there is the function :
void DisplayMessageError(int DllError)
{
char * pMessageError= GetMessageError(DllError);
if(pMessageError){
AfxMessageBox(pMessageError);
delete pMessageError;//!!!!!!!!!!!---------->Problem at this line
}
}
In debug mode when executing the line 'delete pMessageError'
I have the following assertion
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
The Dll seems to have its own heap.
How can I solve this problem ?
JsCHarly