@@ -105,13 +105,19 @@ { if (sec < 0) @throw [OFOutOfRangeException newWithClass: self]; #ifndef _WIN32 - sleep(sec); + if (sec > UINT_MAX) + @throw [OFOutOfRangeException newWithClass: self]; + + sleep((unsigned int)sec); #else - Sleep(sec * 1000); + if (sec * 1000 > UINT_MAX) + @throw [OFOutOfRangeException newWithClass: self]; + + Sleep((unsigned int)sec * 1000); #endif } + (void)sleepForTimeInterval: (int64_t)sec microseconds: (uint32_t)usec @@ -118,14 +124,17 @@ { if (sec < 0) @throw [OFOutOfRangeException newWithClass: self]; #ifndef _WIN32 - sleep(sec); + sleep((unsigned int)sec); usleep(usec); #else - Sleep(sec * 1000 + usec / 1000); + if (sec * 1000 + usec / 1000 > UINT_MAX) + @throw [OFOutOfRangeException newWithClass: self]; + + Sleep((unsigned int)sec * 1000 + usec / 1000); #endif } + (void)sleepUntilDate: (OFDate*)date { @@ -140,13 +149,19 @@ usec = [date microsecondsOfTimeIntervalSinceDate: now]; [pool release]; #ifndef _WIN32 - sleep(sec); + if (sec > UINT_MAX) + @throw [OFOutOfRangeException newWithClass: self]; + + sleep((unsigned int)sec); usleep(usec); #else + if (sec * 1000 + usec / 1000 > UINT_MAX) + @throw [OFOutOfRangeException newWithClass: self]; + Sleep(sec * 1000 + usec / 1000); #endif } + (void)yield