From aeb08b15810632256a067e12840ef7695a9512cf Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Fri, 5 Jul 2013 14:26:48 -0400 Subject: [PATCH] PR14927: protect terminal from invalid vals in SYSTEMTAP_COLORS --- session.cxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/session.cxx b/session.cxx index 3ce0c6cfa..a738de264 100644 --- a/session.cxx +++ b/session.cxx @@ -2085,7 +2085,10 @@ systemtap_session::colorize(std::string str, std::string type) else { // Check if this type is defined in SYSTEMTAP_COLORS std::string color = parse_stap_color(type); - return "\033[" + color + "m\033[K" + str + "\033[m\033[K"; + if (!color.empty()) // no need to pollute terminal if not necessary + return "\033[" + color + "m\033[K" + str + "\033[m\033[K"; + else + return str; } } @@ -2130,8 +2133,13 @@ systemtap_session::parse_stap_color(std::string type) for (unsigned i=0; i