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

Unified Diff: base/time_posix.cc

Issue 10907178: Try to fix the possible bug in base::Time:Now() that can cause the crashing later in icu code calle… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
« ash/system/date/date_view.cc ('K') | « ash/system/date/date_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time_posix.cc
diff --git a/base/time_posix.cc b/base/time_posix.cc
index c79781c3cf58d07c3d7ed4a6fc6094d59fae4fe2..de8f6ea383c2beeb061f54ca1e04c38e149ff641 100644
--- a/base/time_posix.cc
+++ b/base/time_posix.cc
@@ -70,6 +70,10 @@ Time Time::Now() {
struct timezone tz = { 0, 0 }; // UTC
if (gettimeofday(&tv, &tz) != 0) {
DCHECK(0) << "Could not determine time of day";
+ LOG_ERRNO(ERROR) << "Call to gettimeofday failed.";
+ // Return zero instead of uninitialized |tv| value, which contains random
+ // garbage data. This may result in the crash seen in crbug.com/147570.
+ return Time(0L);
brettw 2012/09/11 18:10:23 Use return Time();
jennyz 2012/09/11 18:35:22 Done.
}
// Combine seconds and microseconds in a 64-bit field containing microseconds
// since the epoch. That's enough for nearly 600 centuries. Adjust from
« ash/system/date/date_view.cc ('K') | « ash/system/date/date_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698