don't pass 0 time_t to Borland localtime(), it crashes (bug 1704438); also check for error return from both localtime() and gmtime() [backport from HEAD]
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45574 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -210,7 +210,18 @@ struct tm *wxLocaltime_r(const time_t* ticks, struct tm* temp)
|
|||||||
// thread local storage for localtime anyway.
|
// thread local storage for localtime anyway.
|
||||||
wxMutexLocker locker(timeLock);
|
wxMutexLocker locker(timeLock);
|
||||||
#endif
|
#endif
|
||||||
memcpy(temp, localtime(ticks), sizeof(struct tm));
|
|
||||||
|
// Borland CRT crashes when passed 0 ticks for some reason, see SF bug 1704438
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
if ( !*ticks )
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const tm * const t = localtime(ticks);
|
||||||
|
if ( !t )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
memcpy(temp, t, sizeof(struct tm));
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
#endif // !HAVE_LOCALTIME_R
|
#endif // !HAVE_LOCALTIME_R
|
||||||
@@ -223,6 +234,16 @@ struct tm *wxGmtime_r(const time_t* ticks, struct tm* temp)
|
|||||||
// using thread local storage for gmtime anyway.
|
// using thread local storage for gmtime anyway.
|
||||||
wxMutexLocker locker(timeLock);
|
wxMutexLocker locker(timeLock);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
if ( !*ticks )
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const tm * const t = gmtime(ticks);
|
||||||
|
if ( !t )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
memcpy(temp, gmtime(ticks), sizeof(struct tm));
|
memcpy(temp, gmtime(ticks), sizeof(struct tm));
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user