Skip to content

Commit

Permalink
prevent heap-buffer-overflow in SiPixelDynamicInefficiencyPUParametri…
Browse files Browse the repository at this point in the history
…zation
  • Loading branch information
mmusich committed Mar 3, 2023
1 parent 3d761d8 commit f54c77a
Showing 1 changed file with 16 additions and 1 deletion.
Expand Up @@ -819,10 +819,25 @@ namespace {
int npar = n + 2;
TF1* f1 =
new TF1((fmt::sprintf("region: #bf{%s}", namesOfParts[index - 1])).c_str(), func, xmin_, xmax_, npar);

// push polynomial degree as first entry in the vector
params.insert(params.begin(), n);

// TF1::SetParameters needs a C-style array
double* arr = params.data();
f1->SetLineWidth(2);
f1->SetParameters(arr);

if (n == 1) {
/* special case for constant
using setParameters technically works, but leads to
heap-buffer-overflow
*/
f1->SetParameter(0, arr[0]);
f1->SetParameter(1, arr[1]);
} else {
f1->SetParameters(arr);
}

parametrizations.push_back(f1);

// build the formula to be displayed
Expand Down

0 comments on commit f54c77a

Please sign in to comment.