New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid use of uninitalized values in GBRForestTools #35705
Conversation
Calls to XMLElement::Query*Attribute do not set the passed in variable if there was a problem. So we either need to initialize the variable before hand or check for errors.
bool ctype; | ||
int selector = 0; | ||
float cutval = 0.; | ||
bool ctype = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: I initialized the variables here rather than doing error checking as there is no error handling what so ever in this function and I didn't want to make a larger change.
@@ -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 " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could fail because the attribute is missing or the value could not be converted to a double. I didn't feel it was worth the effort to distinguish the two.
@smuzaffar FYI |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-35705/26011
|
A new Pull Request was created by @Dr15Jones (Chris Jones) for master. It involves the following packages:
@jpata, @cmsbuild, @slava77 can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
please test |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-ccb759/19690/summary.html Comparison SummarySummary:
|
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @perrotta, @dpiparo, @qliphy (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
PR description:
Calls to XMLElement::Query*Attribute do not set the passed in variable if there was a problem. So we either need to initialize the variable before hand or check for errors.
This was found by the compiler in the USBAN build.
PR validation:
Code compiles.