Check for std::string::npos before applying std::string::substr
authorJohn Senneker <johns@matterandform.net>
Tue, 18 Oct 2016 14:48:47 +0000 (10:48 -0400)
committerJohn Senneker <johns@matterandform.net>
Tue, 18 Oct 2016 14:48:47 +0000 (10:48 -0400)
code/ObjFileParser.cpp

index 7859563..e732edd 100644 (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")