catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Added null-ptr check in Colour::use()
- Commit
bbbd5c4e08e0889389179f61fa27210cd77fbbd3- Author
- geh ·
- Committer
- Martin Hořeňovský
- Parents
f41051f22a2e
Changes
include/internal/catch_console_colour.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/internal/catch_console_colour.cpp b/include/internal/catch_console_colour.cpp index 0a13a1bb..1c4799f8 100644 --- a/include/internal/catch_console_colour.cpp +++ b/include/internal/catch_console_colour.cpp @@ -222,7 +222,13 @@ namespace Catch { void Colour::use( Code _colourCode ) { static IColourImpl* impl = platformColourInstance(); - impl->use( _colourCode ); + // Strictly speaking, this cannot possibly happen. + // However, under some conditions it does happen (see #1626), + // and this change is small enough that we can let practicality + // triumph over purity in this case. + if (impl != NULL) { + impl->use( _colourCode ); + } } std::ostream& operator << ( std::ostream& os, Colour const& ) {