Skip to content

Commit

Permalink
Merge pull request #35705 from Dr15Jones/fixUninitGBRForestTools
Browse files Browse the repository at this point in the history
Avoid use of uninitalized values in GBRForestTools
  • Loading branch information
cmsbuild authored Oct 19, 2021
2 parents d401592 + ef94ed3 commit 3c60d77
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions CommonTools/MVAUtils/src/GBRForestTools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ namespace {
} else {
int thisidx = tree.CutIndices().size();

int selector;
float cutval;
bool ctype;
int selector = 0;
float cutval = 0.;
bool ctype = false;

node->QueryIntAttribute("IVar", &selector);
node->QueryFloatAttribute("Cut", &cutval);
Expand Down Expand Up @@ -158,8 +158,12 @@ namespace {
e = e->NextSiblingElement("Info")) {
const char* name;
const char* value;
e->QueryStringAttribute("name", &name);
e->QueryStringAttribute("value", &value);
if (tinyxml2::XML_SUCCESS != e->QueryStringAttribute("name", &name)) {
throw cms::Exception("XMLERROR") << "no 'name' attribute found in 'Info' element in " << weightsFileFullPath;
}
if (tinyxml2::XML_SUCCESS != e->QueryStringAttribute("value", &value)) {
throw cms::Exception("XMLERROR") << "no 'value' attribute found in 'Info' element in " << weightsFileFullPath;
}
info[name] = value;
}

Expand All @@ -172,7 +176,9 @@ namespace {
for (tinyxml2::XMLElement* e = optionsElem->FirstChildElement("Option"); e != nullptr;
e = e->NextSiblingElement("Option")) {
const char* name;
e->QueryStringAttribute("name", &name);
if (tinyxml2::XML_SUCCESS != e->QueryStringAttribute("name", &name)) {
throw cms::Exception("XMLERROR") << "no 'name' attribute found in 'Option' element in " << weightsFileFullPath;
}
options[name] = e->GetText();
}

Expand All @@ -194,7 +200,10 @@ namespace {
e = e->NextSiblingElement("BinaryTree")) {
hasTrees = true;
double w;
e->QueryDoubleAttribute("boostWeight", &w);
if (tinyxml2::XML_SUCCESS != e->QueryDoubleAttribute("boostWeight", &w)) {
throw cms::Exception("XMLERROR") << "problem with 'boostWeight' attribute found in 'BinaryTree' element in "
<< weightsFileFullPath;
}
boostWeights.push_back(w);
}
if (!hasTrees) {
Expand Down

0 comments on commit 3c60d77

Please sign in to comment.