Skip to content

Commit

Permalink
Corrected segfault in for cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
AleCarminati authored and mberaha committed Apr 12, 2022
1 parent 6fae906 commit 40ce3cb
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/algorithms/split_and_merge_algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,10 @@ void SplitAndMergeAlgorithm::proposal_update_allocations(
data_to_move_idx = unique_values[label_old_cluster]->get_data_idx();
}

auto curr_it = data_to_move_idx.cbegin();
auto next_it = curr_it;
next_it++;
auto end_it = data_to_move_idx.cend();
for (; curr_it != end_it; next_it++, curr_it++) {
const unsigned int curr_idx = *curr_it;
if (next_it == end_it) {
for (auto it = data_to_move_idx.cbegin(); it != data_to_move_idx.cend();
it++) {
const unsigned int curr_idx = *it;
if (it == (--data_to_move_idx.cend())) {
if (split) {
unique_values[label_old_cluster]->remove_datum(
curr_idx, data.row(curr_idx), update_hierarchy_params());
Expand Down

0 comments on commit 40ce3cb

Please sign in to comment.