Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3177)

Unified Diff: base/strings/string_number_conversions.cc

Issue 14749003: Stop overwriting errno in base::StringPrintf, StringAppendV, and StringToDouble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comment Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/stringprintf_unittest.cc ('k') | base/strings/string_number_conversions_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/strings/string_number_conversions.cc
diff --git a/base/strings/string_number_conversions.cc b/base/strings/string_number_conversions.cc
index c9b11156ff095e8716c15370881e7ee3e6509555..39daecec9d9c39838004887e653f71fd84cb0c66 100644
--- a/base/strings/string_number_conversions.cc
+++ b/base/strings/string_number_conversions.cc
@@ -12,6 +12,7 @@
#include <limits>
#include "base/logging.h"
+#include "base/scoped_clear_errno.h"
#include "base/third_party/dmg_fp/dmg_fp.h"
#include "base/utf_string_conversions.h"
@@ -450,7 +451,9 @@ bool StringToSizeT(const StringPiece16& input, size_t* output) {
}
bool StringToDouble(const std::string& input, double* output) {
- errno = 0; // Thread-safe? It is on at least Mac, Linux, and Windows.
+ // Thread-safe? It is on at least Mac, Linux, and Windows.
+ ScopedClearErrno clear_errno;
+
char* endptr = NULL;
*output = dmg_fp::strtod(input.c_str(), &endptr);
« no previous file with comments | « base/stringprintf_unittest.cc ('k') | base/strings/string_number_conversions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698