From d0355acb36f0302d067c30ff1c617623abfa94df Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Wed, 2 Jan 2019 10:07:45 -0800 Subject: [PATCH] common: restore constructor fmtflags on clear This is to prevent fmtflags changes from a previous use (e.g. debug message) leaking into the the next (i.e. the next debug message). Signed-off-by: Patrick Donnelly --- src/common/StackStringStream.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/StackStringStream.h b/src/common/StackStringStream.h index 522abc0749a94..352b545d4bcc9 100644 --- a/src/common/StackStringStream.h +++ b/src/common/StackStringStream.h @@ -92,7 +92,7 @@ template class StackStringStream : public std::basic_ostream { public: - StackStringStream() : basic_ostream(&ssb) {} + StackStringStream() : basic_ostream(&ssb), default_fmtflags(flags()) {} StackStringStream(const StackStringStream& o) = delete; StackStringStream& operator=(const StackStringStream& o) = delete; StackStringStream(StackStringStream&& o) = delete; @@ -101,6 +101,7 @@ public: void reset() { clear(); /* reset state flags */ + flags(default_fmtflags); /* reset fmtflags to constructor defaults */ ssb.clear(); } @@ -110,6 +111,7 @@ public: private: StackStringBuf ssb; + fmtflags const default_fmtflags; }; /* In an ideal world, we could use StackStringStream indiscriminately, but alas -- 2.39.5