From 0ea6ed9fc4050b57417d2e7434aa820bb857bff9 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 3 Nov 2015 17:14:56 +0100 Subject: [PATCH] Use memset to clear struct tm before filling fields. This ensures any non-standard fields (e.g. glibc's tm_gmtoff) are clear, as well as the other fields mktime overtly promises to ignore. Change-Id: I45d69eff7b5cb37ab910bf3d4d2d1481fd93aedb Reviewed-by: Marc Mutz --- src/corelib/tools/qdatetime.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 4854ceb5ca..0c4b47d36e 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2236,18 +2236,18 @@ static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStat #else // All other platforms provide standard C library time functions tm local; + memset(&local, 0, sizeof(local)); // tm_[wy]day plus any non-standard fields local.tm_sec = time->second(); local.tm_min = time->minute(); local.tm_hour = time->hour(); local.tm_mday = dd; local.tm_mon = mm - 1; local.tm_year = yy - 1900; - local.tm_wday = 0; - local.tm_yday = 0; if (daylightStatus) local.tm_isdst = int(*daylightStatus); else local.tm_isdst = -1; + #if defined(Q_OS_WIN) int hh = local.tm_hour; #endif // Q_OS_WIN