Throw exception on missing "id" field in configuration
The debug build asserts on the id field, but the release does not have a check for an missing ID field in the configuration. This commit introduces a check that is also performed in the release build to avoid a null ptr dereference in broken config files.master
parent
8cc87025ff
commit
db27ad3ef5
|
@ -174,6 +174,8 @@ std::vector<unsigned int> Cfg::getNext()
|
||||||
unsigned int Cfg::getID()
|
unsigned int Cfg::getID()
|
||||||
{
|
{
|
||||||
XMLAttribute* attr = _elem->getAttribute("id");
|
XMLAttribute* attr = _elem->getAttribute("id");
|
||||||
assert(attr != NULL);
|
if (attr == NULL) {
|
||||||
|
THROWEXCEPTION("Error: Configuration Element '%s' does not have an 'id' field. 'id' is required!", _elem->getName().c_str());
|
||||||
|
}
|
||||||
return atoi(attr->getValue().c_str());
|
return atoi(attr->getValue().c_str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue