Skip to content

Commit

Permalink
Fix negative-wraparound issue when converting size_t to ptrdiff_t whi…
Browse files Browse the repository at this point in the history
…ch is used by std::views::take.

This issue was flagged by VisualStudio debug asserts
  • Loading branch information
clemahieu committed Sep 3, 2024
1 parent 8c8a69b commit 29380eb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nano/node/repcrawler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,9 @@ std::vector<nano::representative> nano::rep_crawler::representatives (std::size_
}

std::vector<nano::representative> result;
for (auto const & [weight, rep] : ordered | std::views::take (count))
for (auto i = ordered.begin (), n = ordered.end (); i != n && result.size () < count; ++i)
{
auto const & [weight, rep] = *i;
result.push_back ({ rep.account, rep.channel });
}
return result;
Expand Down

0 comments on commit 29380eb

Please sign in to comment.