From 364dd416550d0ee1755f5eca77326d5f8dee69f8 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 10 Jan 2016 14:02:03 +0100 Subject: [PATCH] sectionsd: fix possibly fishy localtime_r usage --- src/eitd/sectionsd.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/eitd/sectionsd.cpp b/src/eitd/sectionsd.cpp index c739ab56f..558343e37 100644 --- a/src/eitd/sectionsd.cpp +++ b/src/eitd/sectionsd.cpp @@ -1383,16 +1383,14 @@ void CTimeThread::setSystemTime(time_t tim) { struct timeval tv; struct tm t; - time_t now = time(NULL); - struct tm *tmTime = localtime_r(&now, &t); gettimeofday(&tv, NULL); timediff = int64_t(tim * 1000000 - (tv.tv_usec + tv.tv_sec * 1000000)); + localtime_r(&tv.tv_sec, &t); - xprintf("%s: timediff %" PRId64 ", current: %02d.%02d.%04d %02d:%02d:%02d, dvb: %s", name.c_str(), timediff, - tmTime->tm_mday, tmTime->tm_mon+1, tmTime->tm_year+1900, - tmTime->tm_hour, tmTime->tm_min, tmTime->tm_sec, ctime(&tim)); - + xprintf("%s: timediff %" PRId64 ", current: %02d.%02d.%04d %02d:%02d:%02d, dvb: %s", + name.c_str(), timediff, + t.tm_mday, t.tm_mon+1, t.tm_year+1900, t.tm_hour, t.tm_min, t.tm_sec, ctime(&tim)); #if 0 /* if new time less than current for less than 1 second, ignore */ if(timediff < 0 && timediff > (int64_t) -1000000) {