Skip to content

Commit

Permalink
fix memory error in OMEdit options parser
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke committed Aug 13, 2015
1 parent 23a483a commit 44f0b91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Expand Up @@ -42,5 +42,6 @@ class OMCFactory
std::string _defaultNonLinSolver;
PATH _library_path;
PATH _modelicasystem_path;
std::string _overrideOMEdit; // unrecognized options if called from OMEdit
};
/** @} */ // end of simcorefactoryOMCFactory
18 changes: 8 additions & 10 deletions SimulationRuntime/cpp/SimCoreFactory/OMCFactory/OMCFactory.cpp
Expand Up @@ -218,7 +218,7 @@ std::vector<const char *> OMCFactory::preprocessArguments(int argc, const char*
std::map<std::string, std::string>::const_iterator oit;
std::vector<const char *> optv;
optv.push_back(argv[0]);
std::string override; // OMEdit override option
_overrideOMEdit = "-override="; // unrecognized OMEdit overrides
for (int i = 1; i < argc; i++) {
string arg = argv[i];
int j;
Expand All @@ -240,18 +240,16 @@ std::vector<const char *> OMCFactory::preprocessArguments(int argc, const char*
opts[oit->second] = strs[++j];
}
else {
// leave untreated overrides
if (override.size() > 0)
override += ",";
else
override = "-override=";
override += strs[j];
// leave unrecognized overrides
if (_overrideOMEdit.size() > 10)
_overrideOMEdit += ",";
_overrideOMEdit += strs[j];
if (j < strs.size() - 1)
override += "=" + strs[++j];
_overrideOMEdit += "=" + strs[++j];
}
}
if (override.size() > 10)
optv.push_back(override.c_str());
if (_overrideOMEdit.size() > 10)
optv.push_back(_overrideOMEdit.c_str());
}
else
optv.push_back(argv[i]); // pass through
Expand Down

0 comments on commit 44f0b91

Please sign in to comment.