]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix std::ostream precision settings leak in Progress::print() (#739)
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 27 Oct 2020 16:11:59 +0000 (16:11 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 27 Oct 2020 16:17:33 +0000 (16:17 +0000)
No functionality changes expected.

Broken since inception (commit 8ecbe78d).

Detected by Coverity. CID 1468264: API usage errors(STREAM_FORMAT_STATE)

src/store_rebuild.cc

index eb39f3fc445c6511375e7a99d4ffaa5ff7c0480d..71f343386edc22c99525db35285c7733af273018 100644 (file)
@@ -244,9 +244,10 @@ void
 Progress::print(std::ostream &os) const
 {
     if (goal > 0) {
+        const auto savedPrecision = os.precision(2);
         const auto percent = 100.0 * completed / goal;
-        os << std::setprecision(2) << percent << "% (" <<
-            completed << " out of " << goal << ")";
+        os << percent << "% (" << completed << " out of " << goal << ")";
+       (void)os.precision(savedPrecision);
     } else if (!completed && !goal) {
         os << "nothing to do";
     } else {