diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc --- a/llvm/lib/Support/Unix/Process.inc +++ b/llvm/lib/Support/Unix/Process.inc @@ -332,6 +332,7 @@ // First, acquire a global lock because these C routines are thread hostile. std::lock_guard G(*TermColorMutex); + struct term *previous_term = set_curterm(nullptr); int errret = 0; if (setupterm(nullptr, fd, &errret) != 0) // Regardless of why, if we can't get terminfo, we shouldn't try to print @@ -355,7 +356,7 @@ // Now extract the structure allocated by setupterm and free its memory // through a really silly dance. - struct term *termp = set_curterm(nullptr); + struct term *termp = set_curterm(previous_term); (void)del_curterm(termp); // Drop any errors here. // Return true if we found a color capabilities for the current terminal.