Skip to content

Commit d3d1a47

Browse files
ferdymercuryvepadulano
authored andcommitted
[hist] fix restitution of parameter name containing @
Amends dcf9209#r176468371 see also ferdymercury@1f1cb91 Should make TFormulaTest39 pass again [hist] fix out of bounds access at N-th term
1 parent 39ce914 commit d3d1a47

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

hist/hist/src/TFormula.cxx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,13 +1845,15 @@ void TFormula::HandleLinear(TString &formula)
18451845
TString expandedFormula = "";
18461846
int delimeterPos = 0;
18471847
for(std::size_t iTerm = 0; iTerm < terms.size(); ++iTerm) {
1848-
// determine the position of the "@" operator in the formula
1849-
delimeterPos += terms[iTerm].size() + (iTerm == 0);
1850-
if(IsAParameterName(formula, delimeterPos)) {
1851-
// append the current term and the remaining formula unchanged to the expanded formula
1852-
expandedFormula += terms[iTerm];
1853-
expandedFormula += formula(delimeterPos, formula.Length() - (delimeterPos + 1));
1854-
break;
1848+
if (iTerm < terms.size() - 1) { // N terms, N - 1 @
1849+
// determine the position of the "@" operator in the formula
1850+
delimeterPos += terms[iTerm].size() + iTerm;
1851+
if(IsAParameterName(formula, delimeterPos)) {
1852+
// append the current term and the remaining formula unchanged to the expanded formula
1853+
expandedFormula += terms[iTerm];
1854+
expandedFormula += formula(delimeterPos, formula.Length() - delimeterPos);
1855+
break;
1856+
}
18551857
}
18561858
SetBit(kLinear, true);
18571859
auto termName = std::string("__linear") + std::to_string(iTerm+1);

0 commit comments

Comments
 (0)