Use of potentially dangerous function: localtime
Windows localtime is thread safe and no localtime_r is availabe on
Windows, so use separate logic for Windows.
struct timespec older_than;
memset(&older_than, 0, sizeof(struct timespec));
older_than.tv_sec = LONG_MAX;
- uint32_t poll_seconds = (uint32_t)localtime(&ptv->poll_interval)->tm_sec;
+ uint32_t poll_seconds;
+#ifndef OS_WIN32
+ struct tm safe_tm;
+ memset(&safe_tm, 0, sizeof(safe_tm));
+ poll_seconds = (uint32_t)localtime_r(&ptv->poll_interval, &safe_tm)->tm_sec;
+#else
+ /* windows localtime is threadsafe */
+ poll_seconds = (uint32_t)localtime(&ptv->poll_interval)->tm_sec;
+#endif
if (ptv->should_loop) {
GetTime(&older_than);