Skip to content

Commit 0ba4bd8

Browse files
authored
Check for NULL in XMLNode::Value (#158)
1 parent f330ad3 commit 0ba4bd8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

‎pluginlib/include/pluginlib/class_loader_imp.hpp‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,16 +650,23 @@ void ClassLoader<T>::processSingleXMLPluginFile(
650650
"' has no Root Element. This likely means the XML is malformed or missing.");
651651
return;
652652
}
653-
if (!(strcmp(config->Value(), "library") == 0 ||
654-
strcmp(config->Value(), "class_libraries") == 0))
653+
const char* config_value = config->Value();
654+
if (NULL == config_value) {
655+
throw pluginlib::InvalidXMLException(
656+
"XML Document '" + xml_file +
657+
"' has an invalid Root Element. This likely means the XML is malformed or missing.");
658+
return;
659+
}
660+
if (!(strcmp(config_value, "library") == 0 ||
661+
strcmp(config_value, "class_libraries") == 0))
655662
{
656663
throw pluginlib::InvalidXMLException(
657664
"The XML document '" + xml_file + "' given to add must have either \"library\" or "
658665
"\"class_libraries\" as the root tag");
659666
return;
660667
}
661668
// Step into the filter list if necessary
662-
if (strcmp(config->Value(), "class_libraries") == 0) {
669+
if (strcmp(config_value, "class_libraries") == 0) {
663670
config = config->FirstChildElement("library");
664671
}
665672

0 commit comments

Comments
 (0)