Skip to content

Commit

Permalink
size check
Browse files Browse the repository at this point in the history
Signed-off-by: Dharini Dutia <[email protected]>
  • Loading branch information
quarkytale committed Jan 9, 2024
1 parent 404ffef commit 5a4c1aa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/rendering/MaterialParser/ConfigLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <utility>
#include <vector>

#include <gz/common/Console.hh>
#include <gz/common/Filesystem.hh>
#include "gz/sim/InstallationDirectories.hh"

Expand Down
5 changes: 5 additions & 0 deletions src/rendering/MaterialParser/ConfigLoader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <string>
#include <vector>

#include <gz/common/Console.hh>

namespace gz
{
namespace sim
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/MaterialParser/MaterialParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ std::optional<MaterialParser::MaterialValues> 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;
Expand Down

0 comments on commit 5a4c1aa

Please sign in to comment.