Skip to content

Commit

Permalink
[RF] Set size of offsets vector in LikelihoodJob correctly
Browse files Browse the repository at this point in the history
When `std::copy`ing into a vector, it needs to have the right size
before. Doing only `std::reserve` is not enough.

Fixes root-project#15730.
  • Loading branch information
guitargeek committed Jun 4, 2024
1 parent e97bb9e commit 34bf6a7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion roofit/roofitcore/src/TestStatistics/LikelihoodJob.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void LikelihoodJob::update_state()
assert(!more);
auto offsets_message_begin = offsets_message.data<ROOT::Math::KahanSum<double>>();
std::size_t N_offsets = offsets_message.size() / sizeof(ROOT::Math::KahanSum<double>);
shared_offset_.offsets().reserve(N_offsets);
shared_offset_.offsets().resize(N_offsets);
auto offsets_message_end = offsets_message_begin + N_offsets;
std::copy(offsets_message_begin, offsets_message_end, shared_offset_.offsets().begin());
}
Expand Down

0 comments on commit 34bf6a7

Please sign in to comment.