Avoid using the return value of localtime_r, it's sometimes null on windows.
This commit is contained in:
parent
35a2ca7144
commit
c420a5cbb3
@ -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)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user