Fix crash when using string::erase(i,string::npos)