diff options
author | Chris Robinson <[email protected]> | 2014-04-16 07:52:43 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-16 07:52:43 -0700 |
commit | c6dd4792292194589a535da703c4a3efd10eb6c8 (patch) | |
tree | 4507d5e587c64ba575d2d2b0b4d8addd81aa0a84 | |
parent | 8a51995cfa758617462cb716e744600a42439bcb (diff) |
Make sure the duration given to althrd_sleep is valid
-rw-r--r-- | Alc/threads.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Alc/threads.c b/Alc/threads.c index 2dd85414..cfc8b9e8 100644 --- a/Alc/threads.c +++ b/Alc/threads.c @@ -139,9 +139,15 @@ int althrd_join(althrd_t thr, int *res) int althrd_sleep(const struct timespec *ts, struct timespec* UNUSED(rem)) { DWORD msec; - msec = ts->tv_sec * 1000; - msec += (ts->tv_nsec+999999) / 1000000; + + if(ts->tv_sec < 0 || ts->tv_sec >= (0xffffffffu / 1000) || + ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000) + return -2; + + msec = (DWORD)(ts->tv_sec * 1000); + msec += (DWORD)((ts->tv_nsec+999999) / 1000000); Sleep(msec); + return 0; } |