Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

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.
Commit
188b3e6511b4c1e8fb3266cf185acf92d825cf96
Author
Axel Huebl ·
Committer
Martin Hořeňovský
Parents
bbf70ca74b45

Files · Download .tar.gz

Changes

 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<int>(c);
+        os.flags(f);
     }
 
 } // anonymous namespace