Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b7a8af2

Browse files
committed
Fix _PyTime_AsTimevalStruct_impl() on OpenBSD
On the x86 OpenBSD 5.8 buildbot, the integer overflow check is ignored. Copy the tv_sec variable into a Py_time_t variable instead of "simply" casting it to Py_time_t, to fix the integer overflow check.
1 parent 0d30940 commit b7a8af2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Python/pytime.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static int
454454
_PyTime_AsTimevalStruct_impl(_PyTime_t t, struct timeval *tv,
455455
_PyTime_round_t round, int raise)
456456
{
457-
_PyTime_t secs;
457+
_PyTime_t secs, secs2;
458458
int us;
459459
int res;
460460

@@ -467,7 +467,8 @@ _PyTime_AsTimevalStruct_impl(_PyTime_t t, struct timeval *tv,
467467
#endif
468468
tv->tv_usec = us;
469469

470-
if (res < 0 || (_PyTime_t)tv->tv_sec != secs) {
470+
secs2 = (_PyTime_t)tv->tv_sec;
471+
if (res < 0 || secs2 != secs) {
471472
if (raise)
472473
error_time_t_overflow();
473474
return -1;

0 commit comments

Comments
 (0)