Try the following fix
void TestString(std::string & str)
{
char * tmpBuff = new char[4]; // <<<
tmpBuff[0] = 'f';
tmpBuff[1] = 'o';
tmpBuff[2] = 'o';
tmpBuff[3] = '\0'; // <<<
str = tmpBuff;
delete [] tmpBuff;
}
C-style strings need a terminating \0
character.