Check for std::string::npos before applying std::string::substr

pull/1040/head
John Senneker 2016-10-18 10:48:47 -04:00
parent 4b15dfd9af
commit acd2802f22
1 changed files with 5 additions and 1 deletions

View File

@ -185,7 +185,11 @@ void ObjFileParser::parseFile()
std::string name;
getName(m_DataIt, m_DataItEnd, name);
name = name.substr(0, name.find(" "));
size_t nextSpace = name.find(" ");
if (nextSpace != std::string::npos)
name = name.substr(0, nextSpace);
if (name == "mg")
getGroupNumberAndResolution();
else if(name == "mtllib")