diff --git a/src/vcpkg-test/issue_body.cpp b/src/vcpkg-test/issue_body.cpp index a68d33d928..686e93df66 100644 --- a/src/vcpkg-test/issue_body.cpp +++ b/src/vcpkg-test/issue_body.cpp @@ -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> logs{ diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index 87a0d7e3f9..94ea38118a 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -1533,6 +1533,10 @@ namespace vcpkg void append_logs(std::vector>&& 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();