From 188b3e6511b4c1e8fb3266cf185acf92d825cf96 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 7 Jan 2019 18:19:55 +0100 Subject: [PATCH] hexEscapeChar: restore stream The ostream passed as reference to `hexEscapeChar` is manipulated and its original state not restored. This fixes it. Seen via coverity in a downstream project. --- include/internal/catch_xmlwriter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/internal/catch_xmlwriter.cpp b/include/internal/catch_xmlwriter.cpp index 221f1c63..5354efa7 100644 --- a/include/internal/catch_xmlwriter.cpp +++ b/include/internal/catch_xmlwriter.cpp @@ -44,9 +44,11 @@ namespace { } void hexEscapeChar(std::ostream& os, unsigned char c) { + std::ios_base::fmtflags f(os.flags()); os << "\\x" << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << static_cast(c); + os.flags(f); } } // anonymous namespace