diff --git a/src/rendering/MaterialParser/ConfigLoader.cc b/src/rendering/MaterialParser/ConfigLoader.cc index 497d827d81e..edf6f3335ce 100644 --- a/src/rendering/MaterialParser/ConfigLoader.cc +++ b/src/rendering/MaterialParser/ConfigLoader.cc @@ -23,7 +23,6 @@ #include #include -#include #include #include "gz/sim/InstallationDirectories.hh" diff --git a/src/rendering/MaterialParser/ConfigLoader.hh b/src/rendering/MaterialParser/ConfigLoader.hh index 6a74ce0a8f1..946847871e1 100644 --- a/src/rendering/MaterialParser/ConfigLoader.hh +++ b/src/rendering/MaterialParser/ConfigLoader.hh @@ -25,6 +25,8 @@ #include #include +#include + namespace gz { namespace sim @@ -118,6 +120,9 @@ public: for (const auto & str : m_values) { floatValues.push_back(std::stof(str)); } + if (floatValues.size() < 3) { + gzerr << "Bad material file." << std::endl; + } } inline const std::string & getValue(unsigned int index = 0) diff --git a/src/rendering/MaterialParser/MaterialParser.cc b/src/rendering/MaterialParser/MaterialParser.cc index 7983d25a687..23ffc3832da 100644 --- a/src/rendering/MaterialParser/MaterialParser.cc +++ b/src/rendering/MaterialParser/MaterialParser.cc @@ -51,7 +51,7 @@ std::optional MaterialParser::GetMaterialValues( for (it = scripts.begin(); it != scripts.end(); ++it) { std::string name = it->first; if (name.find(material) != std::string::npos) { - if(!values) { + if (!values) { values = MaterialValues(); } ConfigNode * node = it->second;