diff --git a/tmva/src/MethodBDT.cxx b/tmva/src/MethodBDT.cxx index ab423c772a3dfd0365fed00fb5820fd0741811b0..4ad72a92b204caf4ad24e3047b70198d8ce34a42 100644 --- a/tmva/src/MethodBDT.cxx +++ b/tmva/src/MethodBDT.cxx @@ -1315,12 +1315,12 @@ Double_t TMVA::MethodBDT::GetWeightedQuantile(vector< std::pair<Double_t, Doubl //calculates the quantile of the distribution of the first pair entries weighted with the values in the second pair entries Double_t temp = 0.0; std::sort(vec.begin(), vec.end()); - Int_t i = 0; - while(temp <= norm*quantile){ - temp += vec[i].second; - i++; - } - + UInt_t i = 0; + while(i<vec.size() && temp <= norm*quantile){ + temp += vec[i].second; + i++; + } + if (i >= vec.size()) return 0.; // prevent uncontrolled memory access in return value calculation return vec[i].first; }