I wrote a DLL that does this:
which I call like this, from another dll:
The line that says CRASH does just that (it throws a debug assertion failure about the heap pointer being invalid). So, what's going on? Does the copy constructor for wstring not copy the string? Should I do something to the wstring before I delete it?
Code:
__declspec( dllexport ) wstring * myFunction();
wstring * myFunction () {
wstring result;
// add stuff into result
return new wstring(result);
}
which I call like this, from another dll:
Code:
wstring * mem = myFunction();
// do stuff to mem
delete mem; // CRASH
The line that says CRASH does just that (it throws a debug assertion failure about the heap pointer being invalid). So, what's going on? Does the copy constructor for wstring not copy the string? Should I do something to the wstring before I delete it?