From e34dc1606e1e0c814442d417c6fe02c5db8393e8 Mon Sep 17 00:00:00 2001 From: Stephan Roslen Date: Thu, 15 Oct 2020 21:17:26 +0200 Subject: [PATCH] Fix crash on unset environment variable. --- src/ftxui/screen/terminal.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ftxui/screen/terminal.cpp b/src/ftxui/screen/terminal.cpp index dd0695f..804de09 100644 --- a/src/ftxui/screen/terminal.cpp +++ b/src/ftxui/screen/terminal.cpp @@ -36,7 +36,11 @@ Terminal::Dimensions Terminal::Size() { } bool Terminal::CanSupportTrueColors() { - std::string COLORTERM = std::getenv("COLORTERM"); + char *COLORTERM_RAW = std::getenv("COLORTERM"); + if (nullptr == COLORTERM_RAW) { + return false; + } + std::string COLORTERM = COLORTERM_RAW; return COLORTERM.compare("24bit") || COLORTERM.compare("trueColor"); }