I have the following code:
std::string F()
{
WideString ws = GetMyWideString();
std::string ret;
StringUtils::ConvertWideStringToUTF8(ws, ret);
return ret;
}
WideString is a third-party class, so are StringUtils. They are a blackbox to me. Second parameter is passed by reference.
When I step through the debugger the line return ret
throws a nasty popup (Visual C++) saying that heap may be corrupted. Upon closer examination copy of the string that gets returned is OK, but the deletion of ret
fails. ret
contains correct value before return.
What could the converting function possibly do to cause this? Any ideas to fix?
Update:
- Project itself is a dll
- StringUtils is a lib
- Project is compiled against Multithreaded CRT (not debug, not dll)
- Program seems to run fine when run outside of Visual Studio