diff --git a/include/reporters/catch_reporter_multi.hpp b/include/reporters/catch_reporter_multi.hpp index 9023a3f1..2ffdd751 100644 --- a/include/reporters/catch_reporter_multi.hpp +++ b/include/reporters/catch_reporter_multi.hpp @@ -128,23 +128,18 @@ public: // IStreamingReporter }; Ptr addReporter( Ptr const& existingReporter, Ptr const& additionalReporter ) { - Ptr resultingReporter; + if( !existingReporter ) + return additionalReporter; - if( existingReporter ) { - if( !existingReporter->supportsChainedReporters() ) { - MultipleReporters* multi = new MultipleReporters; - resultingReporter = Ptr( multi ); - if( existingReporter ) - multi->addChainedReporter( existingReporter ); - } - else - resultingReporter = existingReporter; - resultingReporter->addChainedReporter( additionalReporter ); + if( existingReporter->supportsChainedReporters() ) { + existingReporter->addChainedReporter( additionalReporter ); + return existingReporter; } - else - resultingReporter = additionalReporter; - return resultingReporter; + Ptr multi = Ptr( new MultipleReporters ); + multi->addChainedReporter( existingReporter ); + multi->addChainedReporter( additionalReporter ); + return Ptr( multi.get() ); }