mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Trent Mick <trentm@activestate.com>:
This patch fixes a possible overflow in the Sleep system call on Win32/64 in the time_sleep() function in the time module. For very large values of the give time to sleep the number of milliseconds can overflow and give unexpected sleep intervals. THis patch raises an OverflowError if the value overflows. Closes SourceForge patch #100514.
This commit is contained in:
parent
699f352fb2
commit
0e12395190
1 changed files with 11 additions and 4 deletions
|
@ -835,10 +835,17 @@ floatsleep(double secs)
|
|||
}
|
||||
#else /* !MSDOS */
|
||||
#ifdef MS_WIN32
|
||||
/* XXX Can't interrupt this sleep */
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
Sleep((int)(secs*1000));
|
||||
Py_END_ALLOW_THREADS
|
||||
{
|
||||
double millisecs = secs * 1000.0;
|
||||
if (millisecs > (double)ULONG_MAX) {
|
||||
PyErr_SetString(PyExc_OverflowError, "sleep length is too large");
|
||||
return -1;
|
||||
}
|
||||
/* XXX Can't interrupt this sleep */
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
Sleep((unsigned long)millisecs);
|
||||
Py_END_ALLOW_THREADS
|
||||
}
|
||||
#else /* !MS_WIN32 */
|
||||
#ifdef PYOS_OS2
|
||||
/* This Sleep *IS* Interruptable by Exceptions */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue