From: Jonathan Lebon Date: Fri, 5 Jul 2013 18:26:48 +0000 (-0400) Subject: PR14927: protect terminal from invalid vals in SYSTEMTAP_COLORS X-Git-Tag: release-2.3~77 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=aeb08b15810632256a067e12840ef7695a9512cf;p=systemtap.git PR14927: protect terminal from invalid vals in SYSTEMTAP_COLORS --- 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