Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STL problem? or dll issue??? 1

Status
Not open for further replies.

drdad5727

Programmer
Feb 28, 2005
28
US
I wrote a DLL that does this:

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?



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top