Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorSergio Losilla2022-06-02 17:11:12 +0300
committerGitHub2022-06-02 16:11:12 +0200
commit5efd327dd4a638f63396ff22e908f16a8d6b9f20 (patch)
tree5aa7f5bad4e1b096dae66c9b2092402530c4743a /src/catch2
parent40dd9dd3f4cb11d251e4c6e5cd24bf622891bbf0 (diff)
downloadcatch3-5efd327dd4a638f63396ff22e908f16a8d6b9f20.tar.gz
Fix crash when running with --list-listeners and no registered listeners (#2442)
Co-authored-by: Sergio Losilla <sergio.losilla@nt-bnct.com>
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/reporters/catch_reporter_combined_tu.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/catch2/reporters/catch_reporter_combined_tu.cpp b/src/catch2/reporters/catch_reporter_combined_tu.cpp
index 06259433..2d6e112c 100644
--- a/src/catch2/reporters/catch_reporter_combined_tu.cpp
+++ b/src/catch2/reporters/catch_reporter_combined_tu.cpp
@@ -154,6 +154,12 @@ namespace Catch {
void defaultListListeners( std::ostream& out,
std::vector<ListenerDescription> const& descriptions ) {
+ out << "Registered listeners:\n";
+
+ if(descriptions.empty()) {
+ return;
+ }
+
const auto maxNameLen =
std::max_element( descriptions.begin(),
descriptions.end(),
@@ -163,7 +169,6 @@ namespace Catch {
} )
->name.size();
- out << "Registered listeners:\n";
for ( auto const& desc : descriptions ) {
out << TextFlow::Column( static_cast<std::string>( desc.name ) +
':' )