Skip to content

Commit

Permalink
create_github_issue: Fix div by zero (#1275)
Browse files Browse the repository at this point in the history
  • Loading branch information
autoantwort authored Nov 14, 2023
1 parent 365d419 commit 2cbe559
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/vcpkg-test/issue_body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ TEST_CASE ("Testing append_log", "[github-issue-body]")
TEST_CASE ("Testing append_log extra_size", "[github-issue-body]")
{
using namespace vcpkg;
{
std::string out;
append_logs({}, 500, out);
CHECK(out == "");
}
{
std::string out;
std::vector<std::pair<Path, std::string>> logs{
Expand Down
4 changes: 4 additions & 0 deletions src/vcpkg/commands.build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,10 @@ namespace vcpkg

void append_logs(std::vector<std::pair<Path, std::string>>&& logs, size_t max_size, std::string& out)
{
if (logs.empty())
{
return;
}
Util::sort(logs, [](const auto& left, const auto& right) { return left.second.size() < right.second.size(); });
auto size_per_log = max_size / logs.size();
size_t maximum = out.size();
Expand Down

0 comments on commit 2cbe559

Please sign in to comment.