diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-03-30 02:54:57 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-03-30 02:54:57 +0200 |
commit | 86cb6fb8629db8e8d2de9452150dbb50987399ee (patch) | |
tree | 8ea30b90953f436f7210919f0b5e0356b5ed39d1 /Python/pytime.c | |
parent | e86873f59ff36f88f82bc885cf7bc052dee22a15 (diff) | |
download | cpython-86cb6fb8629db8e8d2de9452150dbb50987399ee.tar.gz |
Issue #22117: Add assertions to _PyTime_AsTimeval() and _PyTime_AsTimespec() to
check that microseconds and nanoseconds fits into the specified range.
Diffstat (limited to 'Python/pytime.c')
-rw-r--r-- | Python/pytime.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/pytime.c b/Python/pytime.c index a7eda869a0..0d28911c37 100644 --- a/Python/pytime.c +++ b/Python/pytime.c @@ -360,6 +360,8 @@ _PyTime_AsTimeval_impl(_PyTime_t t, struct timeval *tv, _PyTime_round_t round, if (res && raise) _PyTime_overflow(); + + assert(0 <= tv->tv_usec && tv->tv_usec <= 999999); return res; } @@ -393,6 +395,8 @@ _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts) return -1; } ts->tv_nsec = nsec; + + assert(0 <= ts->tv_nsec && ts->tv_nsec <= 999999999); return 0; } #endif |