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.
This commit is contained in:
Axel Huebl 2019-01-07 18:19:55 +01:00 committed by Martin Hořeňovský
parent bbf70ca74b
commit 188b3e6511
1 changed files with 2 additions and 0 deletions

View File

@ -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