changeset: 95268:49d3ff81f31f user: Victor Stinner date: Mon Mar 30 02:54:57 2015 +0200 files: Python/pytime.c description: Issue #22117: Add assertions to _PyTime_AsTimeval() and _PyTime_AsTimespec() to check that microseconds and nanoseconds fits into the specified range. diff -r d938533b43f7 -r 49d3ff81f31f Python/pytime.c --- a/Python/pytime.c Mon Mar 30 02:51:13 2015 +0200 +++ b/Python/pytime.c Mon Mar 30 02:54:57 2015 +0200 @@ -360,6 +360,8 @@ if (res && raise) _PyTime_overflow(); + + assert(0 <= tv->tv_usec && tv->tv_usec <= 999999); return res; } @@ -393,6 +395,8 @@ return -1; } ts->tv_nsec = nsec; + + assert(0 <= ts->tv_nsec && ts->tv_nsec <= 999999999); return 0; } #endif