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 <marc.mutz@kdab.com>
This commit is contained in:
parent
add58edcdb
commit
0ea6ed9fc4
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user