mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #22117: Add assertions to _PyTime_AsTimeval() and _PyTime_AsTimespec() to
check that microseconds and nanoseconds fits into the specified range.
This commit is contained in:
parent
ea9c0dd2c2
commit
edddf991d9
1 changed files with 4 additions and 0 deletions
|
@ -360,6 +360,8 @@ _PyTime_AsTimeval_impl(_PyTime_t t, struct timeval *tv, _PyTime_round_t round,
|
||||||
|
|
||||||
if (res && raise)
|
if (res && raise)
|
||||||
_PyTime_overflow();
|
_PyTime_overflow();
|
||||||
|
|
||||||
|
assert(0 <= tv->tv_usec && tv->tv_usec <= 999999);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,6 +395,8 @@ _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ts->tv_nsec = nsec;
|
ts->tv_nsec = nsec;
|
||||||
|
|
||||||
|
assert(0 <= ts->tv_nsec && ts->tv_nsec <= 999999999);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue