Avoid using the return value of localtime_r, it's sometimes null on windows.

This commit is contained in:
Jean-Francois Dockes 2015-11-15 16:07:01 +01:00
parent 6d7a1c01f8
commit 481ca31786

View file

@ -1422,11 +1422,11 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc)
time_t mtime = atoll(doc.dmtime.empty() ? doc.fmtime.c_str() : time_t mtime = atoll(doc.dmtime.empty() ? doc.fmtime.c_str() :
doc.dmtime.c_str()); doc.dmtime.c_str());
struct tm tmb; struct tm tmb;
struct tm *tmbp = &tmb; localtime_r(&mtime, &tmb);
tmbp = localtime_r(&mtime, &tmb); char buf[9];
char buf[9]; snprintf(buf, 9, "%04d%02d%02d",
snprintf(buf, 9, "%04d%02d%02d", tmb.tm_year+1900, tmb.tm_mon + 1, tmb.tm_mday);
tmbp->tm_year+1900, tmbp->tm_mon + 1, tmbp->tm_mday);
// Date (YYYYMMDD) // Date (YYYYMMDD)
newdocument.add_boolean_term(wrap_prefix(xapday_prefix) + string(buf)); newdocument.add_boolean_term(wrap_prefix(xapday_prefix) + string(buf));
// Month (YYYYMM) // Month (YYYYMM)